Firebase数据库:无此类实例字段错误

时间:2018-11-15 13:58:01

标签: android firebase firebase-realtime-database

我正在尝试从Firebase数据库检索数据,但没有任何帮助。调试器告诉我,databaseRefer和mFirebaseInstance变量中没有“没有这样的实例字段”。有人可以帮我吗?

  private void setUser() {

    currUserEmail = FirebaseAuth.getInstance().getCurrentUser().getEmail().replace(".",",");
    DatabaseReference userData = FirebaseDatabase.getInstance().getReference("Users");
    Query a=userData.orderByChild("email").equalTo(currUserEmail);
    a.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            curr_user = null;
            for(DataSnapshot singleSnapshot : dataSnapshot.getChildren()) {
                curr_user = singleSnapshot.getValue(User.class);
            }
            if (curr_user == null){
                String currUserEmail = FirebaseAuth.getInstance().getCurrentUser().getEmail().replace(".",",");
                DatabaseReference userData = FirebaseDatabase.getInstance().getReference("Users").child(currUserEmail);
                userData.setValue(new User (currUserEmail,FirebaseAuth.getInstance().getCurrentUser().getUid()));
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}

my database

0 个答案:

没有答案