Suppose that I have a data store like this.
but I want only username
and profileImage
. What method should I use for this case?
The first one is query data in two times. Something like this...
usersRef.child(uid).child("username").addValueListener...
String username = dataSnapshot.getValue(String.class);
usersRef.child(uid).child("profileImage").addValueListener...
String profileImage = dataSnapshot.getValue(String.class);
or
The second one is get all children only one time and get only data that I want. Something like this...
- userRef.addValueListener...
User user = new User();
datasnapshot.getValue(user.class)
String username = user.username;
String profileImage = user.profileImage;