In your Database Reference make sure you are having the correct path to the data your are retrieving, like
DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("your/path/to/data");
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
//making sure snapshot consists some data
if (dataSnapshot.exists()) {
//do your stuff
User userDashboard = dataSnapshot.getValue(User.class);
USERNAME.setText(userDashboard.getName().toString().trim());
PASSWORD.setText(userDashboard.getPassword().toString().trim());
EMAIL.setText(userDashboard.getEmail().toString().trim());
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(UserDashboard.this, "Database Error", Toast.LENGTH_LONG).show();
}
});
1
solved Android Frebase User Data Retrieve [closed]