I want to read specific data from firebase database. What I am currently doing is here.
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) {}
});
Method to write to DB
public void writeToDBProfiles(Object data,String phoneNo) {
DatabaseReference database = FirebaseDatabase.getInstance().getReference();
DatabaseReference myRef = database.child("profiles/" + phoneNo);
myRef.setValue(data);
}
But its returning null... Any help will be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…