mAuth = FirebaseAuth.getInstance();
mFirebaseDatabase = FirebaseDatabase.getInstance();
myRef = mFirebaseDatabase.getReference().child(\"Users\");
Fi
First get uid of the current user that is logged in:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String userid = user.getUid();
then retrieve the data of the current user:
DatabaseReference ref = FirebaseDatabase.getInstance().getReference("Users");
ref.child(userid).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String name = dataSnapshot.child("name").getValue().toString();
name1.setText(name);
}
Assuming you have this:
Users
userid
name: peter
//etc