title: how to wait untill the data is sent Firebase
body: <p>I have a little problem, I'm implemented a sign out button, the thing is that when I press the button to logout the app crashes because my user now is null and meanwhile it's uploading to the database some files, so at the time it needs to reach the user to post the data, the user is null. is there a way to know or wait till the uploads to firebase are done and then logout, or I need to implement a timer?</p>
  
  <pre><code> @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          addPreferencesFromResource(R.xml.preferences);
  
          mAuth = FirebaseAuth.getInstance();
          mAuthListener = new FirebaseAuth.AuthStateListener() {
              @Override
              public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
  
                  if(firebaseAuth.getCurrentUser() == null){
                      Intent mainIntent = new Intent().setClass(
                              prefs.this, LoginActivity.class);
                      startActivity(mainIntent);
                      finish();
  
                  }
  
              }
          };
  </code></pre>
  
  <p>I have this listeners all over the place to check if the user is logged in or not. </p>
  
  <p>And this is my signout button</p>
  
  <pre><code>  Preference button = findPreference(getString(R.string.pref_header_cerrar_sesion));
                  button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
                      @Override
                      public boolean onPreferenceClick(Preference preference) {
  
  
                          FirebaseAuth.getInstance().signOut();
                          finish();
  
  
                          return true;
                      }
                  });
  </code></pre>