Previously, I asked to get the data in firebase. But I can't get the value... My database like this.
{Singer :
{Eminem :
{01 :
songName : "Rap god",
songType : "type01"
},
{02 :
songName : "Till I collapse",
songType : "type02"
}
},
{Lauv :
{01 :
songName : "I Like Me Better",
songType : "type01"
},
{02 :
songName : "lonely",
songType : "type03"
}
},
{Alan Walker :
{01 :
songName : "All Falls Down",
songType : "type02"
},
{02 :
songName : "On My Way",
songType : "type01"
}
}
}
I want to get all type01
in Singer
all of them. I tried code like this
@Override
public void onBindViewHolder(@NonNull MyHolder holder, int i) {
...
Query myQuery = FirebaseDatabase.getInstance().getReference().child("Singer").orderByChlid("songType").equalsTo("type01");
FirebaseRecyclerOption.Builder<ItemModel>.setQuery(myQuery, new SanpshotParser<ItemModel>() {
@NonNull
@Override
public ItemModel parseSnapshot(@NonNull DataSnapshot snapshot) {
String songStr = snapshot.child("songName").getValue().toString();
String typeStr = snapshot.child("songType").getValue().toString();
return new ItemModel(songStr, typeStr);
}
}).build();
...
}
But I can't get what I want. FirebaseDatabase.getInstance().getReference().child("Singer").orderByChild("songType").equalsTo("type01")
can't read the data in function parseSnapshot
. How can I get all the singer's songs that type is type01
?