I'm trying to retrieve all child nodes "userID" from firebase and store them in userList array list. Datasnapshot object dsp pulls all the data but it can't pass it to userList which always empty. Here is my code snippet:
groupList = FirebaseDatabase.getInstance ().getReference ().child ( "Group Members" );
groupList.addValueEventListener(new ValueEventListener()
{
@Override
public void onDataChange( DataSnapshot dataSnapshot)
{
List<String> userList = new ArrayList<> ();
for (DataSnapshot dsp : dataSnapshot.getChildren ())
{
String uID = dsp.child ("userID").getValue().toString ();
userList.add ( uID );
}
}
What do you suggest to change in the code?