如何从Firebase数据库中检索特定用户的所有收到的消息?
答案 0 :(得分:0)
FirebaseDatabase database;
DatabaseReference databaseReference;
database = FirebaseDatabase.getInstance();
databaseReference = database.getReference("firebase_db_name);
DatabaseReference databaseReference = databaseReference.child("your_user");
databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot != null) {
YOUR_OBJECT object =
dataSnapshot.getValue(YOUR_OBJECT.class);
// todo in object you will get all your msgs
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});