I have this DB:
users: {
0 : {
name: xx
age: 11
books:{
0 : true
3 : true
}
}
1 : {
name: yy
age: 12
books:{
1 : true
4 : true
}
}
}
I have ref to db als:
database = FirebaseDatabase.getInstance();
refdb = database.getReference();
and query als:
Query = refdb.child("users");
i need to get all pairs (name:value) and for users pairs of books (id:true) als:
0 : true
3 : true
I'm using this to get pairs (id:true):
refdb.child("users").child("books").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
pck.setText(pack);
for (DataSnapshot dttSnapshot2 : dataSnapshot.getChildren()) {
pack = dttSnapshot2 .getKey().toString()+":"+dttSnapshot2 .getValue().toString();
pck.append(pack);
}
...
Where pck is a textView. My problem is that everytime he print the empty string in textView. How can I get those data and write them in a textview?