问题
I have generated the push id of the user who have sign up.
String id=databaseUser.push().getKey();
How I can get this id when the user signs in?
Please help me on this.
回答1:
You can store that id in the database as a property of your User object but a more elegant way would be to use the uid
and not that random key provided by the push()
method. So once you are authenticated, you can get the uid
, using the following line of code:
String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
来源:https://stackoverflow.com/questions/51348025/how-to-get-the-push-id-of-current-user-in-firebase-android