How To Sort By Children Key Value In Firebase?
I am trying to sort projects based on the dateAdded: The tree looks like this: projects: { 'someprojectId': { dateAdded: Firebase.TimeStamp }, 'someProjectid2':
Solution 1:
It would help to see how you actually handle the data in onDataChange
. But my guess is that you're failing to loop over the children:
mDatabase
.child("projects")
.orderByChild("dateAdded")
.addValueEventListener(new ValueEventListener() {
public void onDataChange(DataSnapshot snapshot) {
for (DataSnapshot child: snapshot.getChildren()) {
System.out.println(child.getKey());
}
}
...
Post a Comment for "How To Sort By Children Key Value In Firebase?"