Android Firebase Query

僤鯓⒐⒋嵵緔 提交于 2019-12-21 12:20:09

问题


I have this structure 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.


回答1:


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.




回答2:


I had the same problem and solve it by changing listener:

myRef.orderByChild("ci").equalTo("6991580").addChildEventListener(new ChildEventListener() {}



来源:https://stackoverflow.com/questions/37579872/android-firebase-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!