Reputation: 369
When the user logs into my app, I want to store his UID somewhere in the app because I do certain offline functionalities with the UID. My requirement is that, once he logs in, I should be able to store the UID somewhere by retrieving it from firebase. Once that is done, unless he logs out, I need to be able to access this UID locally on the app to certain processes from various different activities. Only when he logs out, this UID can be deleted. If he quits the app, or the internet connection is lost, my ability to access this UID string shouldn't be affected. What is the best place to store this UID?
Upvotes: 0
Views: 35
Reputation: 11326
Firebase Auth already takes care of keeping the UID at all times for you. You can access it using the code showed on the documentation:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
// User is logged in
String uid = user.getUid(); //this is the stored uid
} else {
// User is logged out
}
Upvotes: 2