My Firebase Realtime Database is like this :
{Singer :
Billie Eilish :
01 :
songType : "type01"
songName : "bad guy"
02 :
songType : "type02"
songName : "bury a friend"
Lauv :
01 :
songType : "type01"
songName : "I Like Me Better"
02 :
songType : "type03"
songName : "lonely"
Anne Marie :
01 :
songType : "type02"
songName : "2002"
...
...
...
}
If I want to get all the song that "type01", what should I do? This is my Adapter class that show the data in recyclerView in MainActivity.
Adapter class :
public class MyAdapter extends Recycler.Adapter {
...
@Override
public void onBindViewHolder(@Nonnull ViewHolder holder, int i) {
...
Query query = FirebaseDatabase.getInstance().getReference().child("Singer");
options = new FirebaseRecyclerOptions.Builder<ItemModel>().setQuery(query, new SnapshotParser<ItemModel>() {
@NonNull
@Override
public ItemModel parseSnapshot(@NonNull DataSnapshot snapshot) {
if (snapshot.child("songType").getValue().toString().equals("type01") {
String song = snapshot.child("songName").getValue().toString();
return new ItemModel(song);
}
return null;
}
}).build();
recyclerAdapter = new AnotherAdapter(options);
recyclerAdapter.startListening();
}
I think it is weird in the query. It called only the child "Singer". I want to call all the child and get what songType is "type01". AnotherAdapter is just extending FirebaseReyclcerAdapter and just set the text in its AnotherViewHolder.