How can I retrieve data from getUID.push() on Firebase DataBase I would like get all data under push() like name, status and age?
Can you help me? here is my database enter image description here
Asked
Active
Viewed 86 times
-1

Gabriel Nogueira
- 5
- 1
- 4
-
Please add your database structure. – Alex Mamo Jul 31 '18 at 20:53
-
I put a image on my question , can you see that? – Gabriel Nogueira Aug 01 '18 at 12:21
1 Answers
0
Assuming that you have implemented Firebase authentication and Adultos
node is a direct child of your Firebase root, to get those keys, please use the following code:
String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference uidRef = rootRef.child("Adultos").child(uid);
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot ds : dataSnapshot.getChildren()) {
String key = ds.getKey();
Log.d("TAG", key);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {}
};
uidRef.addListenerForSingleValueEvent(valueEventListener);
Te output in your logcat will be all those pushed ids highlighted in red.

Alex Mamo
- 130,605
- 17
- 163
- 193
-
Can i use that on my RecyclerView? Because i want get data from push and list that – Gabriel Nogueira Aug 01 '18 at 12:35
-
Yes you can. **[This](https://stackoverflow.com/questions/49383687/how-can-i-retrieve-data-from-firebase-to-my-adapter/49384849)** is a recommended way in which you can retrieve data from a Firebase Realtime database and display it in a `RecyclerView` using `FirebaseRecyclerAdapter`. – Alex Mamo Aug 01 '18 at 12:44
-
Thanks a lot , i will follow all your steps and return your post. – Gabriel Nogueira Aug 01 '18 at 12:52
-
-
Let's stick to one question at a time. Have you got the ids using my above code? – Alex Mamo Aug 01 '18 at 13:39
-
The issue regarding the `RecyclerView` is basically another question that I cannot answer in a comment and without the necessary code and in order to follow the rules of this comunity, please post another fresh question, so me and other users can help you. – Alex Mamo Aug 01 '18 at 13:42