Firebase实时数据库无法正常工作

时间:2017-06-10 14:12:51

标签: android firebase firebase-realtime-database

当我尝试向firebase数据库添加数据时没有任何反应

   @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    database=FirebaseDatabase.getInstance();
    reference=database.getReference("comment");
    uploadButton=(ImageButton) findViewById(R.id.uploadButton);
     uploadButton.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {


       reference.setValue("zizo");
     }
 });

注意:手机已连接到互联网,我写了用户使用互联网的权限

1 个答案:

答案 0 :(得分:0)

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    DatabaseReference database = FirebaseDatabase.getInstance().getReference().child("comment");
     uploadButton=(ImageButton) findViewById(R.id.uploadButton);
    uploadButton.setOnClickListener(new View.OnClickListener() {
      @Override
        public void onClick(View v) {


   reference.setValue("zizo");
 }
 });