0

I'm currently using Firebase email authentication as the sign in method. However, when I register new user, the email of the new user will only save to the Authentication panel rather than my Realtime Database. And now I would like to add on more information for the particular user. What should I do now?

Is there a way whenever new user is registered, the email of the new user will save to the Authentication panel and Realtime Database?

I have no idea how to retrieve the user email from Authentication. I know there might be a way to get the user email which is by using "user UID"? But may I know how to do it?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • See https://stackoverflow.com/a/39077364/209103, https://stackoverflow.com/a/41531764/209103, https://stackoverflow.com/a/38682667/209103 and possibly some more from [this list](https://stackoverflow.com/search?tab=votes&q=%5bfirebase-authentication%5d%5bandroid%5d%20save%20user%20to%20database) – Frank van Puffelen Jan 20 '19 at 15:14

1 Answers1

1

You need to explicitly add the email of the user while signup using the following line of code.Call the code inside mAuth.createUserWithEmailAndPassword().Set the email from the edit text.

public void onComplete(@NonNull Task<AuthResult> task) {
                if (task.isSuccessful()) {
                    FirebaseDatabase.getInstance().getReference().child("my_users_email")
                                    .child(task.getResult().getUser().getUid())
                                    .child("Email").setValue(Email.getText().toString());}