I have a database that looks like this:
database
|
places
|
user1
| |___indoors: "yes"
| |___outdoors: "yes"
|
user2
|___indoors: "yes"
|___outdoors: "no"
When I do the following, I get all users places information as a single object (converted to String) with no problems:
ValueEventListener placesListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String locations = dataSnapshot.toString(); // I get the entire tree as String
}
}
//this is how I set the listener to changes
DatabaseReference database = FirebaseDatabase.getInstance().getReference();
DatabaseReference reference = database.child("places");
reference.addValueEventListener(placesListener);
But, when I want only the indoors
children, I get DataSnapshot {key = indoors, value = null}
.
This is how I try to get only the indoors
keys and values (almost the same, only adding extra .child("indoors")
:
ValueEventListener placesListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String indoors = dataSnapshot.child("indoors").toString(); // I get value = null
}
}
// listener remains the same