title: Get Firebae Database Data passing to object
body: <p>I'm facing an problem with my app. When the user registers in the app, automatticaly it is created a &quot;profile&quot; of the user in a database, where the Uid is the child:</p>
  <p><a href="https://i.stack.imgur.com/5Slp6.png" rel="nofollow noreferrer">Firebase User Data</a></p>
  <p>After the Login in the app is the app calls the activity2. On start it is suppost to load the user information into a class:</p>
  <pre><code>{
      tUsers.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(@NonNull DataSnapshot snapshot) {
  
              if (snapshot.child(fauth.getUid()).child(&quot;uBirthday&quot;).exists()) {
              }
              else {
  
  //userData is created when activity2 is called
  
                userData= (snapshot.child(fauth.getUid()).getValue(Class_UserData.class));
                
                Log.i(&quot;MainActivity inside&quot;, &quot;User: &quot; + userData.getUserName() + &quot; Email: &quot; + userData.getUserEmail());    
              }
          }
          @Override
          public void onCancelled (@NonNull DatabaseError error){
              return;
          }
      });
  </code></pre>
  <p>Below Class_UserData:</p>
  <pre><code>
      String uName;
      String uEmail;
      String UserBirthday;
      String UserGender;
      int UserPhoto;
  
  
      public Class_UserData(String userName, String userEmail) {
          uName = userName;
          uEmail = userEmail;
      }
  
      public Class_UserData(String userName, String userEmail, String userBirthday, String userGender) {
          uName = userName;
          uEmail = userEmail;
          UserBirthday = userBirthday;
          UserGender = userGender;
      }
  
      public Class_UserData() {
      }
  
      public void setUserName(String userName) {
          uName = userName;
      }
  
      public void setUserEmail(String userEmail) {
          uEmail = userEmail;
      }
  
      public void setUserBirthday(String userBirthday) {
          UserBirthday = userBirthday;
      }
  
      public void setUserGender(String userGender) {
          UserGender = userGender;
      }
  
      public String getUserName() {
          return uName;
      }
  
      public String getUserEmail() {
          return uEmail;
      }
  
      public String getUserBirthday() {
          return UserBirthday;
      }
  
      public String getUserGender() {
          return UserGender;
      }
  }
  </code></pre>
  <p>When inside the onDataChange the class is working. OutSide the class it returns null. Any ideas how to solve this?</p>