title: how to get the same id in firebase auth and firebase - real time database?
body: <p>How do I get same id for firebase auth and firebase realtime database?
  When user register their account, they will get their id in the database, but then I realized that the Id is different? how to make sure I have the same Id for both database?
  <a href="https://i.stack.imgur.com/GHIb1.png" rel="nofollow noreferrer">Different Id</a></p>
  
  <pre><code>//create customer
  firebaseAuth.createUserWithEmailAndPassword(email, password)
          .addOnCompleteListener(RegisterActivity.this, new OnCompleteListener&lt;AuthResult&gt;() {
              @Override
              public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                  if (task.isSuccessful()) {
                      authData = firebaseAuth.getUid();
                      String id = databaseReference.push().getKey();
                      Customer info = new Customer(id, name, email, address, telephone_number);
                      FirebaseDatabase.getInstance().getReference("Customer")
                              .child(Objects.requireNonNull(FirebaseAuth.getInstance().getCurrentUser()).getUid())
                              .setValue(info).addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() {
                          @Override
                          public void onComplete(@NonNull Task&lt;Void&gt; task) {
                              regProgressBar.setVisibility(View.VISIBLE);
                              Toast.makeText(RegisterActivity.this, "Registration Complete", Toast.LENGTH_SHORT).show();
                              startActivity(new Intent(getApplicationContext(), MainActivity.class));
                          }
                      });
                  }
              }
          });
  
  
  </code></pre>
  
  <pre><code> FirebaseDatabase.getInstance().getReference("Customer")
                                              .child(Objects.requireNonNull(FirebaseAuth.getInstance().getCurrentUser()).getUid())
  </code></pre>
  
  <p>I've tried replace the coding above with this</p>
  
  <pre><code> FirebaseDatabase.getInstance().getReference("Customer")
                                              .child(id)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/25o07.png" alt="same id where i want to achieve"></p>
  
  <p>I got the same id but then i encounter another problem where my profile activity cannot be displayed </p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.example.gerobokgo.Model.Customer.name' on a null object reference</p>
  </blockquote>
  
  <p>so i decided to change the first coding back.</p>