Lucian Comșa
Lucian Comșa

Reputation: 51

Getting data from firebase Database

So, this is how my json database looks

**JSON**

I need to grab information from this

**section**

The problem is that all the children of this element have the null value.(I am only interested in their key which is represented by push ids) My program should return a list of the keys.(or part of them). Any ideas on how do I do it in android studio ?

Here is my code that gets executed to retrieve..still not working..any ideas on what am I doing wrong..?

Upvotes: 1

Views: 86

Answers (1)

Yunus Kulyyev
Yunus Kulyyev

Reputation: 1022

Use DataSnapshot.getKey() to get the key. You can loop through all the children by using:

for (DataSnapshot childSnapshot : dataSnapshot.getChildren()) {
    String key = childSnapshot.getKey();
}

Upvotes: 2

Related Questions