After authenticating the user and updating the FirebaseUser
table, I would need to save other extra data such as age, gender, address etc. I would like to use the R
That's correct, to get the current user's unique ID you can use:
FirebaseUser.getInstance().getCurrentUser().getUid();
And you can then store details about a user into the Firebase Realtime Database using that unique ID as a key, something like:
FirebaseUser user = FirebaseUser.getInstance().getCurrentUser();
String userId = user.getUid();
DatabaseReference usersRef = FirebaseDatabase.getInstance().getReference("users");
HashMap userDetails = new HashMap<>();
message.put("name", "P. Sherman");
message.put("age", 50);
message.put("gender", "male");
message.put("address", "42 Wallaby Way, Sydney");
message.put("email", user.getEmail());
messagesRef.child(userId).setValue(userDetails);