Firebase Realtime database getvalue() not mapping the object

后端 未结 4 799
长发绾君心
长发绾君心 2021-01-25 00:41

This is my firebase chat structure(see image below). I want to get only amitpal_name value not the others but this method fetching me all the values
I had also use this

4条回答
  •  北海茫月
    2021-01-25 01:07

    check the answer for this post this may help: I want to list all unique childrens and keys along with values in a spinner firebase

    In this, you can see how to fetch each of the node values then key along with their values.

     mUserDatabase.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
    
            for (DataSnapshot childDataSnapshot : dataSnapshot.getChildren()) {
    
             //"It will give you all node values:"+dataSnapshot.getKey()
            //"You can check ": 
    
              if(dataSnapshot.getKey()=="amitpal"){
                for (DataSnapshot childDataSnapshot2 : childDataSnapshot.getChildren()) {
    
             // "CHILD KEY"+childDataSnapshot2.getKey()
    
                    arrayList.add(childDataSnapshot2.getKey());
    
             //"CHILD VALUES"+childDataSnapshot2.getValue()
    
                }}
    
                }
    
        }
        @Override
        public void onCancelled(DatabaseError databaseError) {
    
        }
    });
    

提交回复
热议问题