How to sort by children key value in firebase?

后端 未结 1 471
陌清茗
陌清茗 2020-12-10 23:19

I am trying to sort projects based on the dateAdded:

The tree looks like this:

projects: {
    \"someprojectId\": {
       dateAdded: Firebase.TimeSt         


        
相关标签:
1条回答
  • 2020-12-11 00:17

    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());
          }
        }
        ...
    
    0 讨论(0)
提交回复
热议问题