尽管这个问题来自基础。我想在回收者视图中打印用户的所有子级,如何使Firebase看起来像这样
Root
|
|_users
|
|_john
|_paul
|_//other names....
答案 0 :(得分:1)
尝试如下
DatabaseReference mDatabase;
mDatabase = FirebaseDatabase.getInstance().getReference();
DatabaseReference mRef = mDatabase.getReference();
mDatabase.child("users").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot: snapshot.getChildren()) {
String name = postSnapshot.getValue();
//do what you want
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}
});