I have integrated firebase auth with my android app. Lets say a user has a mail [email protected]. I want to add some extra information to the user like the name of the user, occupation and address. How can i connect the user auth table with my android app to do that?

Do i need to write any APIs for that?

Solution 1

First, create a users directory in db. Then, using user's unique id you get from authn process, store the user info under users/{userid}.

To achieve this, you need to get into the details of Firebase database. See here:

Solution 2

You do not need to write any custom code to do this. Firebase already has features you can use.

The first thing you'd need to do is ensure that users have access to only the data they store. To do this, go to Database/Rules and change your rules to this:

"rules": {
  "my_app_user": {
    "$uid": {
      ".write": "auth != null && auth.uid == $uid",
      ".read": "auth != null && auth.uid == $uid"

Then, to save the new details in a Firebase database, do this:

        MyAppUser user = new MyAppUser();

                                   new OnCompleteListener<Void>() {
                    public void onComplete(@NonNull Task<Void> task) {
                        if (task.isSuccessful()) {

The name of the child my_app_user must match both in your code and the Firebase rules else it won't persist.

If everything goes as is supposed to, you should see the details in your database:

Solution 3

You have to create another database table say "user". On successful signin, signup for first time you have to create a new row in user table.

public static void writeNewUser(DatabaseReference databaseReference, String userId, String name, String email, int accountType) {
    User user = new User(name, email, accountType);


You may refer