I am storing user's display name in Firebase Auth. Fetching from Firebase Auth is simple when the same user is logged in. But, when another user is logged in, how do I fetch an account's display name when I have their unique UID (User ID).
Asked
Active
Viewed 1.1k times
2 Answers
3
One solution is when you register a user add his details in database also
Example
Once you are under createUserWithEmailandPassword()
DatabaseReference db=FirebaseDatabase.getInstance().getReference();
DatabaseReference users = db.child("Users").child(mAuth.getCurrentUser().getUid());
users.child("Name").setValue("<NAME>");
Now when the user signs into your database retrieve the Name from the database from child Users

CopsOnRoad
- 237,138
- 77
- 654
- 440

Dwijraj Bhattacharyya
- 351
- 4
- 14
2
You can't get the name, or any other details of a user that is not currently signed in using FirebaseAuth
.
Instead, you must create a node in your database where you store the name, and any other necessary details by querying the database.
I'm really curious to know how you have the UID of any other user without doing this.

Rohit Navarathna
- 418
- 2
- 8