Firebase android: how to retrieve all users contact and show them using recyclerview ? help me please. thank you in advance.
Asked
Active
Viewed 59 times
-1
-
Possible duplicate please try googling before asking here in community thanks. Check this link https://stackoverflow.com/questions/43293935/how-to-get-child-of-child-value-from-firebase-in-android – Cyrille Con Morales Sep 05 '19 at 02:39
-
No... Look at the image of my database. I want to select child who have different parents – deslok Sep 05 '19 at 07:31
-
Thumbs up, btw Ill make a solution just wait for the answer – Cyrille Con Morales Sep 05 '19 at 07:34
-
For future reference, it’s a good idea to include code and structures as *text*, not links and images. That way, if they are needed in an answer, they can be copied and pasted. To get your Firebase structure, use the Firebase console->Export JSON and copy and paste a snippet of your structure. See [images and links are evil](http://idownvotedbecau.se/imageofcode) – Jay Sep 05 '19 at 18:50
1 Answers
0
Based on your database structure
Your database structure is kind a broken but you can try this
Users = FirebaseDatabase.getInstance().getReference("users");
Contacts = FirebaseDatabase.getInstance().getReference("users");
Users.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot userKeys:dataSnapshot.getChildren()){
//get All the users
final String users = userKeys.getKey();
//get contacts
Contacts.child(users).child("contact").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot contacts:dataSnapshot.getChildren()){
String contact = contacts.getValue(String.class);
Toast.makeText(getApplicationContext(),contact+"of"+users,Toast.LENGTH_SHORT).show();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
//end of get contact
}
//End of for each
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});

Cyrille Con Morales
- 918
- 1
- 6
- 21
-
-
Please... how to display the list of contacts that I retrieved using recyclerview – deslok Sep 05 '19 at 08:34
-
Actually it will be a long convo when we continue this but search it on youtube for tutorials it would be easy to understand. – Cyrille Con Morales Sep 05 '19 at 08:37