title: Firebase open different activity based on different value stored in database
body: <p>I am checking if the current user is logged into my app and has never once signed out. If it is true, and upon launching my app, it will open Activity A/B, depending on the value of <code>userDepartment</code> stored in database.</p>
  
  <p>My codes are like this:</p>
  
  <pre><code>        firebaseAuth = FirebaseAuth.getInstance();
      FirebaseUser user = firebaseAuth.getCurrentUser();
  
      //user has logged in and never once logged out. auto bring to the specific dashboard page based on account type.
      if (user != null) {
          finish();
          final String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
          DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference().child("userDepartment").child(uid);
          if (databaseReference.equals("Administrator")) {
              startActivity(new Intent(MainActivity.this, SecondActivity.class));
          } else {
              startActivity(new Intent(MainActivity.this, LocalUserDashboard.class));
          }
      }
  </code></pre>
  
  <p>The logic is not working as when I signed in as Administrator, close the app but DID NOT sign out, the expected outcome is the Administrator user will be brought to <code>SecondActivity</code> class. However, it opened up the <code>LocalUserDashboard</code> class instead. Then, if I login as Local User, close the app and did not sign out, it does bring me to the <code>LocalUserDashboard</code> class, just as intended.</p>
  
  <p>I am not entirely sure if my codes are right as I did it while depending on various sources both in SO as well as the official documents and kinda just mixing everything up.</p>
  
  <p>Please help me. Thank you.</p>
  
  <p>Below is my database structure:</p>
  
  <p><a href="https://i.stack.imgur.com/79YOu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/79YOu.jpg" alt="enter image description here"></a></p>