title: Why can't I read data from Firebase database?
body: <p>I'm new to Firebase and I don't understand why I'm not able to get the data in tMAX and same variables(tMAX always returns as 0.0 and same as 0). I tried many things that I found but with all of them I get the same result when debugging.
  What am I doing wrong? 
  Is this the right way to read from the database? Have I missed something?</p>
  
  <p>Strings.java -here is where I do the reading</p>
  
  <pre><code>public class Settings {
      double tMAX;
      int NumNodes;
      int LastNode;
      int Source;
      int same;
  
      DatabaseReference mFirebaseDatabase;
      FirebaseDatabase mFirebaseInstance;
      String userID;
      public Settings()  {
          mFirebaseInstance=FirebaseDatabase.getInstance();
          userID= FirebaseAuth.getInstance().getCurrentUser().getUid();
          mFirebaseDatabase=mFirebaseInstance.getReference().child("user").child(userID).child("1");
          mFirebaseDatabase.addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(@NotNull DataSnapshot snapshot) {
                  for(DataSnapshot snapshot1: snapshot.getChildren()){
                      if(snapshot != null){
                          User user = snapshot1.getValue(User.class);
                          if(user != null){
                              tMAX = user.getDuration();
                          }
                      }
                  }
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
                  Log.e("Settings", "loadPost:onCancelled", databaseError.toException());
              }
          });
  
          NumNodes=31;
  
          mFirebaseDatabase.child("2").addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(@NotNull DataSnapshot snapshot) {
                  for(DataSnapshot snapshot1: snapshot.getChildren()){
                      if(snapshot != null){
                          User2 user = snapshot1.getValue(User2.class);
                          if(user != null){
                              same=user.getSourceDestination().get(0);
                              if(same==1){
                                  NumNodes+=1;
                                  Source=0;
                                  LastNode=0;
                              }
                              else{
                                  NumNodes+=2;
                                  Source=0;
                                  LastNode=32;
                              }
                          }
                      }
                  }
  
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
                  Log.e("Settings", "loadPost:onCancelled", databaseError.toException());
              }
          });
  
      }
  }
  </code></pre>
  
  <p>And this is how my database looks
  <a href="https://imgur.com/a/5HTHsfT" rel="nofollow noreferrer">https://imgur.com/a/5HTHsfT</a></p>