title: Can't write to Firebase database from Auth success listener
body: <p>I am using Firebase auth (email and password), and a Firebase database.
  I am trying to write to the database upon successful registration.
  I am using the simple database writing query, as provided by the Firebase assistant:</p>
  
  <pre><code>// Write a message to the database
  FirebaseDatabase database = FirebaseDatabase.getInstance();
  DatabaseReference myRef = database.getReference("message");
  myRef.setValue("Hello, World!");
  </code></pre>
  
  <p>It does work if I write it simply under the <code>onCreate</code> method of the activity, but when I write it inside the Auth success listener, the account does register, but the message is not written to the database:</p>
  
  <pre><code>// [START sign_in_with_email]
  mAuth.signInWithEmailAndPassword(email, password)
          .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
              @Override
              public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                  if (task.isSuccessful()) {
  
                      // Write a message to the database
                      FirebaseDatabase database = FirebaseDatabase.getInstance();
                      DatabaseReference myRef = database.getReference("message");
                      myRef.setValue("Hello, World!");
  
                      FirebaseUser user = mAuth.getCurrentUser();
                      updateUI(user);
            //rest of code 
  }
  </code></pre>