Vinicius DSL Vinicius DSL - 2 months ago 15
Android Question

Android Firebase Query

I have this structure
enter image description here
Now, Im making a query like this:

DatabaseReference myRef = database.getReference("users");
myRef.equalTo("6991580","ci").addListenerForSingleValueEvent(new ...


I was expecting the second node as result.. Then I get:


DataSnapshot { key = users, value = null }


So, what is wrong with this query? or maybe Im doing something wrong?

Best regards and thanks for reply.

Answer

You need to tell Firebase what child property you want to order/filter on:

myRef.orderByChild("ci").equalTo("6991580").addListenerForSingleValueEvent(...

The other format of ordering is a commonly misunderstood version. I'd recommend simply staying away from it.

Comments