I need to get the email address from uid
of one user (not the current user). My database has one child called "users" and this one has children which keys are the uid of the all the users. I need to get the email address of the other users by their uid.
String uidReceiver = "B53Bk4dtHjZ6a3ZjoO2cEowEf4w2";
DatabaseReference usersRef;
usersRef = FirebaseDatabase.getInstance().getReference().child("users");
// To get the email address of the current user
FirebaseUser userSender = FirebaseAuth.getInstance().getCurrentUser();
String emailSender = userSender.getEmail();
usersRef.child(uidReceiver).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists())
{
// How can I get the email address of uidReceiver
}
}
@Override
public void onCancelled(DatabaseError databaseError) {}
});
Thanks!