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
change your below line
String chatis=(String) ((DataSnapshot)iterator.next()).getValue();
to
String chatis=((DataSnapshot)iterator.next()).getValue().toString();
Updated method below
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
Log.e( "OUTER ADDED IS-" , dataSnapshot.getValue().toString());
Iterator iterator=dataSnapshot.getChildren().iterator();
while (iterator.hasNext()){
DataSnapshot local = (DataSnapshot) iterator.next();
String chatis=local.getValue().toString();
Log.e( "Inner ADDED IS-" , chatis);
}
}
EDIT
also below line as well after the reference initialization
dbreference.keepSynced(true);