Reputation: 1054
I'm using Firebase. Where I need to fetch the record for a particular attribute. But when I have used the Firebase query method, I'm unable to get the actual result. Following is my code:
Firebase ref = ZopOrderingAplication.getFirebaseInstance();
Firebase retailerMastRef = ref.child("Retailer_Master");
Here s the query I'm using:
Query queryRef = retailerMastRef.orderByChild("user_name").equalTo("8105409301","user_name");
Here is the function I'm using to fetch the records:
queryRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
long getChildCount = dataSnapshot.getChildrenCount();
Log.i(TAG,"getChildCount: "+getChildCount);
//Retailer_Master retailerObj = dataSnapshot.getValue(Retailer_Master.class);
//Log.i(TAG,"retailer phone queryRef: "+retailerObj.getPhone());
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
Here is the data in my firebase databse:
Upvotes: 0
Views: 455
Reputation: 2872
I think you need to try this:
Query queryRef = retailerMastRef.orderByChild("user_name").equalTo("8105409301");
Remove user_name from equalTo() as you have it in orderByChild.
Hope this helps. Do let me know if it changes anything for you.
Upvotes: 1