To get it out of the way, yes there is a similar question on SO, but it doesn't explain exactly what my situation asks for I think.
In the Firebase Realtime Database, I have a json tree that looks something like this:
users{
userid{
templates{
templateName1{ // example name that the user saves their template as.
// each template is an ArrayList
//templateName1 ArrayList contents
}
templateName2{
//templateName1 ArrayList contents
}
templateName2{
//templateName1 ArrayList contents
}
}
}
}
I need to be able to list each template in "templates", and at other times simply get the ArrayList value of a specific template. However I can't seem to figure out how to do this simple thing.
From what I've googled/read in the docs, my code should look something like this:
DatabaseReference mTemplateRef = mDatabase.child("users").child(uid).child("templates");
mTemplateRef.addListenerForSingleValueEvent(
new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
dataSnapshot.getChildren();
// somehow get the values here
}
});
When I debug, and enter the expression data dataSnapshot.getChildren() I can see the contents as expected, but I can't seem to get that data into my app. Any ideas?