0

i have list of user id from firebse how to retrive all data of these users in a recycleview

This is my firebase data:

enter image description here

these are user id i want to retrive all user data please

this is my code:

Query query = FirebaseDatabase.getInstance().getReference("Users")
                            .orderByChild(id);

query.addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(@NonNull DataSnapshot snapshot) {
        User user = snapshot.getValue(User.class);
        user_list.add(user);
        Log.d(TAG, "User added");

    }

    @Override
    public void onCancelled(@NonNull DatabaseError error) {
        error.toException();
    }
});

after i get id i try to get all users , but i get empty recycle view

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 1
    Please show us the content of your `User` class. Besides that, to understand better, do you only need a list of those UIDs? – Alex Mamo Mar 10 '23 at 11:21
  • There is not enough context here for us to answer. Please edit your question to provide: 1) The data at `/Users` in your database including the `Users` node itself (as text, no screenshot please). You can get this by clicking the "Export JSON" link in the overflow menu (⠇) on your [Firebase Database console](https://console.firebase.google.com/project/_/database/data). --- 2) The value of `id`, or better yet: reproduce the problem with a hard-coded value instead, and show the code for that. --- 3) The output you expect the code to give, and the output you get instead. – Frank van Puffelen Mar 10 '23 at 15:30
  • All that said: are you simply forgetting to call `notifyDataSetChanged` on your adapter? See for an example: https://stackoverflow.com/questions/55252138/populating-recycler-view-from-nested-queries-in-firebase/55303932#55303932 and https://stackoverflow.com/questions/44858947/contactnames-from-phonebook-with-numbers-from-firebase/44862773#44862773 – Frank van Puffelen Mar 10 '23 at 15:32

0 Answers0