Reputation: 171
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!
Upvotes: 1
Views: 1917
Reputation: 3313
If you mean that you want to get the email of the user from FirebaseAuth
using his uid, then it's not possible from android client. Only firebase admin who can get the email of the user from the FirebaseAuth
, and android sdk has NO admin permissions. You need to add the email to the Firebase Database in order to get the email of the needed user.
Upvotes: 3