android firebase - get childrens count

前端 未结 1 856
北海茫月
北海茫月 2020-12-02 00:34

Here is my Firebase data

{
\"ques\": {
\"Chemistry\": {},
\"Countries\": {},
\"Film\": {},
\"Geography\": {},
\"General Knowledge\": {},
\"Information Techn         


        
相关标签:
1条回答
  • 2020-12-02 01:16
      Firebase.setAndroidContext(this);
      DatabaseReference fbDb = null;
      if (fbDb == null) {
          fbDb = FirebaseDatabase.getInstance().getReference();
      }
    
    
      fbDb.child("ques/Technology")
          .addListenerForSingleValueEvent(new ValueEventListener() {
               @Override
               public void onDataChange(DataSnapshot dataSnapshot) {
                   // get total available quest
                    int size = (int) dataSnapshot.getChildrenCount();
                }
                @Override
                public void onCancelled(DatabaseError databaseError) {
    
                }
            });
    
    0 讨论(0)
提交回复
热议问题