I am working on android app where Firebase
is being used for maintaining mobile back end. I have database in this format on Firebase
{
In order to display the data, you need change your code like this:
mDatabase.child("users").child(userId).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String firstName = dataSnapshot.child("firstName").getValue(String.class);
Log.d("Scheduled", firstName);
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
}
});
In which userId
is the unique id generated by the push()
method.