tailor :
I have a predefined List<String>
. Now in my app I retrieved data from Firebase database. Generally I used:
DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
Query query = reference.child("Users").orderByChild("id").equalTo("string");
But for more stuff I want to filter data from my List<String>
. So is this possible like below query?
Query query = reference.child("Users").orderByChild("id").equalTo(***String_exists_in_predefined_list***);
Alex Mamo :
So is this possible like below query ??
No, it's not possible. You cannot pass a list of strings as the second argument to the equalTo()
method because there is no such a method that accepts that. You need to iterate over the list and create a query for each one of those elements and merge the result client side.
Edit:
You need to loop through the list and create a query for each element:
for(String element : list) {
Query query = reference.child("Users").orderByChild("id").equalTo(element);
}