title: How to read and display from realtime database [Firebase]?
body: <p>I tried following various youtube videos for guides in order to display the current user information in user profile.However, I still failed on displaying those data. Those data are name, gmail and phone numbers.</p>
  <p>My current java code on ProfileActivity</p>
  <pre><code>
      FirebaseUser user;
      DatabaseReference reference;
      String userID;
  
      Button MainMenu,Logout;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_profile);
  
          user = FirebaseAuth.getInstance().getCurrentUser();
          reference = FirebaseDatabase.getInstance().getReference(&quot;users&quot;);
          userID = user.getUid();
  
          final TextView ViewName = (TextView) findViewById(R.id.Name);
          final TextView ViewEmail = (TextView)  findViewById(R.id.Email);
          final TextView ViewPhonenumber = (TextView)  findViewById(R.id.Phonenumber);
  
          reference.child(userID).addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  users userProfile = snapshot.getValue(users.class);
  
                  if(userProfile != null){
                      String name = userProfile.Name;
                      String email = userProfile.Email;
                      String phonenumber = userProfile.Phonenumber;
  
  
                      ViewName.setText(name);
                      ViewEmail.setText(email);
                      ViewPhonenumber.setText(phonenumber);
                  }
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
                  Toast.makeText(ProfileActivity.this,&quot;Something wrong happened&quot;,Toast.LENGTH_LONG).show();
              }
          });
  </code></pre>
  <p>My current file for users.java</p>
  <pre><code>
      public String Name;
      public String Email;
      public String Phonenumber;
  
      public users(){
  
      }
  
      public String getName() {
          return Name;
      }
  
      public void setName(String name) {
          Name = name;
      }
  
      public String getEmail() {
          return Email;
      }
  
      public void setEmail(String email) {
          Email = email;
      }
  
      public String getPhonenumber() {
          return Phonenumber;
      }
  
      public void setPhonenumber(String phonenumber) {
          Phonenumber = phonenumber;
      }
  }
  </code></pre>
  <p>My realtime database in Firebase
  <a href="https://i.stack.imgur.com/BBfs7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BBfs7.png" alt="enter image description here" /></a></p>
  <p>UPDATED with Register.java class so you guys might get clear view on how my code looks like</p>
  <pre><code>
      EditText mFullName,mEmail,mPassword,mPhone;
      Button mRegisterButton;
      TextView mLoginButton;
      FirebaseAuth fAuth;
      ProgressBar progressBar;
      FirebaseDatabase db = FirebaseDatabase.getInstance();
      DatabaseReference root = db.getReference().child(&quot;users&quot;);
  
      users users;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_register);
  
          mFullName           = findViewById(R.id.Name);
          mEmail              = findViewById(R.id.Email);
          mPassword           = findViewById(R.id.Password);
          mPhone              = findViewById(R.id.Phonenumber);
          mRegisterButton     = findViewById(R.id.registerbutton);
          mLoginButton        = findViewById(R.id.loginpage);
  
  
          fAuth = FirebaseAuth.getInstance();
          progressBar = findViewById(R.id.progressBar);
  
          if(fAuth.getCurrentUser() != null)
          {
              startActivity(new Intent(getApplicationContext(),MainActivity.class));
  
          }
  
  
          mRegisterButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  String email = mEmail.getText().toString().trim();
                  String password = mPassword.getText().toString().trim();
                  String name = mFullName.getText().toString();
                  String number =mPhone.getText().toString();
  
                  HashMap&lt;String , String&gt; userMap = new HashMap&lt;&gt;();
  
                  userMap.put(&quot;name&quot;,name);
                  userMap.put(&quot;email&quot;,email);
                  userMap.put(&quot;phone&quot;,number);
  
  
  
                  if(TextUtils.isEmpty(email))
                  {
                      mEmail.setError(&quot;Email is required!&quot;);
                      return;
                  }
  
                  if(TextUtils.isEmpty(password))
                  {
                      mPassword.setError(&quot;Password is required!&quot;);
                      return;
                  }
  
                  if(password.length() &lt; 6)
                  {
                      mPassword.setError((&quot;Password must be longer than 6&quot;));
                      return;
                  }
  
                  progressBar.setVisibility(View.VISIBLE);
  
                  fAuth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(new OnCompleteListener&lt;AuthResult&gt;() {
                      @Override
                      public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                          if(task.isSuccessful()){
                              root.child(FirebaseAuth.getInstance().getCurrentUser().getUid()).setValue(userMap);
                              Toast.makeText(Register.this,&quot;User Created&quot;,Toast.LENGTH_LONG).show();
                              startActivity(new Intent(getApplicationContext(),MainActivity.class));
  
                          }else{
                              Toast.makeText(Register.this,&quot;Error&quot; + task.getException().getMessage(),Toast.LENGTH_SHORT).show();
                              progressBar.setVisibility(View.GONE);
  
                          }
                      }
                  });
              }
          });```
  </code></pre>