我想从firebase数据库中读取特定数据.我目前正在做的是这里.
DatabaseReference database = FirebaseDatabase.getInstance().getReference();
DatabaseReference myRef = database.child("profiles/");
myRef.child(phoneNo).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
user = dataSnapshot.getValue(User.class);
}
@Override
public void onCancelled(DatabaseError databaseError) {}
});
写入DB的方法
public void writeToDBProfiles(Object data,String phoneNo) {
DatabaseReference database = FirebaseDatabase.getInstance().getReference();
DatabaseReference myRef = database.child("profiles/" + phoneNo);
myRef.setValue(data);
}
但它返回null …任何帮助将不胜感激.