Home > database >  Populating RecyclerView with all of the childs of Realtime Database with certain value
Populating RecyclerView with all of the childs of Realtime Database with certain value

Time:05-18

I have to populate a RecyclerView with all of the children that have favourite = true, this is my database structure: https://i.stack.imgur.com/7C6Ys.png

EDIT The response I was looking is in the comments provided by alex

val queryByFav = db.child("Users").child("mikeyreid2002gmailcom").orderByChild("favourite").equalTo(true)

CodePudding user response:

To be able to return all children which have the favourite = true, the following query is required:

val db = FirebaseDatabase.getInstance().reference
val queryByFav = db.child("Users").orderByChild("testing provider a/favourite").equalTo(true);

This query will work only if all the other users have the exact same structure:

testing provider a/favourite

If they don't, then make sure to have a fixed child and not a dynamic one.

  • Related