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
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) {
}
});