mehmet
mehmet

Reputation: 1598

FirebaseUser How to get a User from Uid

I want to reach a user profile page. how can call a specific user with firebaseAuth. this code gives me only current user. how can call a user with user id.

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

are there any code like this:

FirebaseUser user = FirebaseAuth.getInstance().getUser(mywantuserID);

why I want to use FirebaseAuth otherwise profile updates will take my time.

Upvotes: 2

Views: 3183

Answers (3)

Kurt Acosta
Kurt Acosta

Reputation: 2557

I believe the FirebaseAuth object only has the capability to get the currently signed-in user's details.

Maybe you could create a User object in your schema and have the UID from the Firebase Users as the key:

users
---UID
------first_name
------last_name
------etc...

And then with that, you get a user's ID with a simple Firebase Query like:

FirebaseDatabase.getReference('users').orderByKey().equalTo(yourUID)

Upvotes: 1

Oussema Aroua
Oussema Aroua

Reputation: 5339

if you need an other user detail you need to store what you need at the firebase you can't use the auth method

Upvotes: 1

Nirel
Nirel

Reputation: 1925

To get user uid, simple use user.geUid();, for example:

    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    String userUid = user.getUid());

Firebase documentations

Upvotes: -1

Related Questions