Reputation: 255
How I can select key of “Notifications
” with value “Show Again
” if true
?
This is my query but it’s not working.
String startAtKey = "order_trinhvanminh2009@gmail,com";
//Query to get the notification in orders is allow showing.
Query queryNotification = dataNotification.orderByChild("order")
.startAt(true, startAtKey).endAt(true, startAtKey).orderByChild("Notifications")
.orderByChild("Show Again").equalTo(true);
Here’s my database structure:
Upvotes: 1
Views: 578
Reputation: 6035
All you have to do is access child of object like this.!
mdatabaseRef.child("order").child("order_trinhvanminh2009@gmail,com_12").child("Notifications").child("order_order_trinhvanminh2009@gmail,com_12_notification_0").orderByChild("Show Again").equals("true").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String value = (String) dataSnapshot.getValue();
}
all you have to do is nested query
dataSnapshot.getChildren();
mdatabaseRef.child("order").child(dataSnapshot.getChildren()).
mdatabaseRef.child("order").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot child: dataSnapshot.getChildren()){
String key = child.getKey();
fun(key);
}
private void fun(String key){
mdatabaseRef.child("order").child(key).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {for (DataSnapshot child: dataSnapshot.getChildren()){
String key = child.getKey();
fun(key);
}
}
Upvotes: 1