PC. PC. -4 years ago 52
Android Question

Not able to pull up values from Firebase database on Android

This is my JSON data structure in Firebase database:

|- 0
| |-- 0:"FGH"
| |-- 1:"HJU"
|-- code: "2222"
|-- family: "SWE"
|-- fatherName: "ABC"
|-- motherName: "XYZ"

My code for retrieving
data from firebase-database:

DatabaseReference childrenKeyReference = FirebaseDatabase.getInstance().getReference().child("familylist").child("children").child(key);
Log.d(TAG, "children: " + childrenKeyReference);
childrenKeyReference.addValueEventListener(new ValueEventListener() {
public void onDataChange(DataSnapshot dataSnapshot) {
String child = (String) dataSnapshot.getValue();
Log.d(TAG, "Child : " + child);
public void onCancelled(DatabaseError databaseError) {}

This are the details from LogCat. Null values are getting displayed. I'm not able to figure out what's wrong. Please do correct me.

05-22 21:25:29.771 24743-24743/D/tag: children: https://bcm.firebaseio.com/familylist/children/0
05-22 21:25:29.774 24743-24743/D/tag: children: https://bcm.firebaseio.com/familylist/children/1
05-22 21:25:29.780 24743-24743/D/tag: Child : null
05-22 21:25:29.805 24743-24743/D/tag: Child : null

Answer Source

You may have switched the nodes access order by accident ;)

You are currently doing this:


but maybe you should be doing:


since, according to your datamodel, familylist clearly doesn't have a children child node.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download