This is my Customer's Node
customers
{
"-KXKCee0yVJE1z1gCQcV" : {
"cust_id" : "-KXKCee0yVJE1z1gCQcV",
"email" : “xxx@xxx.com",
"food_pref" : "nonveg",
"name" : “Jind",
"notes" : "",
"phone" : “123"
},
"-KXMVChcSwfUif-xVbRa" : {
"cust_id" : "-KXMVChcSwfUif-xVbRa",
"email" : “ggg@ggg.com",
"food_pref" : "nonveg",
"name" : “Mani",
"notes" : "Butter Chicken!!!",
"phone" : “456"
},
"-KXV4eYM6bKNniE_oLEf" : {
"cust_id" : "-KXV4eYM6bKNniE_oLEf",
"email" : “vvv@vvv.com",
"food_pref" : "veg",
"name" : "Jay",
"notes" : "",
"phone" : “789"
}
}
I'm using the following query to check Phone Number
Query query = reference.child("customers").orderByChild("phone").equalTo("789");
How do I check if the value "789" exists?
Tried doing
query.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot.exists())
Log.d(TAG, dataSnapshot.getKey());
else
Log.d(TAG, "Not Found");
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
This does not work.Any alternate for checking this?