0

I am using android studio which is connected to Firebase database I only want to fetch first id from users table how can I do that?

enter image description here

KENdi
  • 7,576
  • 2
  • 16
  • 31
Ahsan Abbas
  • 45
  • 1
  • 4

2 Answers2

0

You will have to access the node's children in order to get their values, as far as I understand. You can check this other posts in order to better understand how: Getting children data and Getting children ID

P. Vera
  • 315
  • 4
  • 11
0

So, assuming that you know the ID already, which is userID

private DatabaseReference mDatabase;
mDatabase = FirebaseDatabase.getInstance().getReference().child("users").child(userId);    

  ref.addListenerForSingleValueEvent(new ValueEventListener() {
  @Override
  public void onDataChange(DataSnapshot dataSnapshot) {

    // Manipulate your data here

  }

  @Override
  public void onCancelled(FirebaseError firebaseError) {

  }
});
Hussam
  • 1,606
  • 9
  • 20
  • Thanks for answering can you please tell the code to write in manipulate your date here ? – Ahsan Abbas Feb 12 '19 at 17:24
  • You can use `userClassObject = getValue(userClass.class)` to get all your user info. I suggest you read the official docs to get more idea on what DataSnapshot is and how fetch desired data from it. https://firebase.google.com/docs/reference/android/com/google/firebase/database/DataSnapshot – Hussam Feb 13 '19 at 18:24