This is my firebase database json:
{
"trucks" : {
"-KvLTRmYdJKuYKZfila6" : {
"busiHours" : "월~금 09:00-22:00 강남역",
"imgUrl" : "https://firebasestorage.googleapis.com/v0/b/movetodiner.appspot.com/o/trk11.png?alt=media&token=7971b439-7321-4496-bf7d-2564fa799f53",
"starCount" : 1,
"stars" : {
"FJB7BWTdlyfCdzXJN4pwmSQWa1E3" : true
},
"truckDes" : "즉석 츄러스 전문점",
"truckName" : "스윗 츄러스",
"truckNo" : "1"
},
"-KvLTo5_eWVWxSAhemK4" : {
"busiHours" : "월~일 09:00-19:00 홍대입구역",
"imgUrl" : "https://firebasestorage.googleapis.com/v0/b/movetodiner.appspot.com/o/trk11.png?alt=media&token=7971b439-7321-4496-bf7d-2564fa799f53",
"starCount" : 1,
"stars" : {
"FJB7BWTdlyfCdzXJN4pwmSQWa1E3" : true
},
"truckDes" : "수제 케밥을 알고싶니?",
"truckName" : "오빠 손맛",
"truckNo" : "2"
},
"-KvLTxrGs9tAs3w5jJVV" : {
"busiHours" : "화, 목, 토,일 10:00-23:00 이태원",
"imgUrl" : "https://firebasestorage.googleapis.com/v0/b/movetodiner.appspot.com/o/trk11.png?alt=media&token=7971b439-7321-4496-bf7d-2564fa799f53",
"starCount" : 0,
"truckDes" : "백종원이 추천한다!",
"truckName" : "도깨비 핫도그",
"truckNo" : "3"
},
"-KvLU4ViXM78aH_thFjF" : {
"busiHours" : "ggg",
"imgUrl" : "https://firebasestorage.googleapis.com/v0/b/movetodiner.appspot.com/o/trk11.png?alt=media&token=7971b439-7321-4496-bf7d-2564fa799f53",
"starCount" : 2,
"stars" : {
"FJB7BWTdlyfCdzXJN4pwmSQWa1E3" : true,
"Jm7JQQBGtzQgLUBgcEutB3O6YAV2" : true
},
"truckDes" : "6~7",
"truckName" : "nonono",
"truckNo" : "4"
},
"-KvLUCR-pBjQot6R1Cj6" : {
"busiHours" : "TT",
"imgUrl" : "https://firebasestorage.googleapis.com/v0/b/movetodiner.appspot.com/o/trk11.png?alt=media&token=7971b439-7321-4496-bf7d-2564fa799f53",
"starCount" : 0,
"truckDes" : "8~10",
"truckName" : "Twice",
"truckNo" : "5"
}
}
}
I want to retreive favorite List.
Query : Select * from trucks where stars (contains) FJB7BWTD~~;
F7B7 is my uid.
It will generate uid in starsfield if users click the favorite button.
So i want to check my uid in stars at every object.
So i thought it needs a query.
But it is not working.
enter code here
Query mQuery=database.getReference().child("trucks").orderByChild("stars").equalTo(auth.getCurrentUser().getUid());
mQuery.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot : dataSnapshot.getChildren())
{
favlist.add(postSnapshot.getValue().toString());
System.out.println(postSnapshot.getKey() + " / " +postSnapshot.getValue().toString() + " / ");
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Program skiped the my code.....;;
How to write code? Let me explain exatly.