I want to retrieve multiple child with an auto generated child(Estab_url child). Here is my Code. All i can retrieve is one child and its random
final DatabaseReference establishments = database.getReference("establishments");
establishments.child(s2).child("Estab_url").addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot.hasChildren()) {
// String value = dataSnapshot.getValue(String.class);
String sd = dataSnapshot.getKey();
Name.setText(sd);
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…