首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >未添加到防火墙数据库中的数据

未添加到防火墙数据库中的数据
EN

Stack Overflow用户
提问于 2016-09-08 16:24:49
回答 3查看 3.3K关注 0票数 1

我从这里获得了Firebase教程,并遵循了本教程中的每一步。但是,当我单击create button并刷新firebase时,我得到的数据库数据总是空的。

有人能帮我找出问题所在吗?

这是我的firebase

Config.java

代码语言:javascript
运行
复制
public class Config {
    public static final String FIREBASE_URL = "https://healthy-app-30d65.firebaseio.com/";   
}

寄存器

代码语言:javascript
运行
复制
public class Register extends AppCompatActivity {
    EditText editTextName;
    EditText editTextAddress;
    TextView textViewPersons;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register);
        Firebase.setAndroidContext(this);
        Button buttonSave = (Button) findViewById(R.id.buttonSave);
        editTextName = (EditText) findViewById(R.id.editTextName);
        editTextAddress = (EditText) findViewById(R.id.editTextAddress);
        textViewPersons = (TextView) findViewById(R.id.textViewPersons);

        //Click Listener for button
        buttonSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Creating firebase object
                Firebase ref = new Firebase(Config.FIREBASE_URL);

                //Getting values to store
                String name = editTextName.getText().toString().trim();
                String address = editTextAddress.getText().toString().trim();

                //Creating Person object
                Person person = new Person();

                //Adding values
                person.setName(name);
                person.setAddress(address);

                //Storing values to firebase
                ref.child("Person").setValue(person);
            }
        });
    }


}
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-09-08 16:45:43

我建议你遵循最新的火源样本。您可以在Google Firebase Codelab中找到一步一步的设置和示例项目。

例如,将值存储到实时数据库将被更新。

ref.child("Person").setValue(person);ref.child("Person").push().setValue(person);

票数 0
EN

Stack Overflow用户

发布于 2016-09-08 21:19:32

您正在使用为遗留Firebase控制台(firebase.com)和SDK版本(2.x)编写的教程。但是Firebase项目是在新的Firebase控制台(firebase.google.com)上创建的。

虽然大部分API将继续工作,但这里有一些不同之处:

  1. 在新控制台上创建的项目被配置为只允许经过身份验证的用户读写。(暂时)解决这个问题的最简单方法是读取此文档页上蓝色的第一个注意事项。这说明了如何再次使数据库世界可读性/可写性。
  2. 来自Firebase 2.xSDK的身份验证不会针对在新的Firebase控制台上创建的项目工作。

因此,#1可能是一个很好的快速解决办法,但您确实应该学习一个更新的教程,如其他答案中建议的教程。

票数 3
EN

Stack Overflow用户

发布于 2016-09-08 16:50:33

新的Firebase与遗留代码(https://wwww.firebase.com)不兼容,您必须将您的安卓项目设置为最新的SDK。关于如何迁移数据库代码,您可以参考这个链接

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39396017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档