Firebase how to use orderbychild

那年仲夏 提交于 2019-12-24 19:05:04

问题


medics/randomid/medicname = someValue

I want this medic name get listview with firebase

dref = FirebaseDatabase.getInstance().getReference().child("users").child(kullaniciuid).child(medic).orderByChild("medicname");

dref.addChildEventListener(new ChildEventListener() {
    @Override
    public void onChildAdded(DataSnapshot dataSnapshot, String s) {


        ss = dataSnapshot.getValue().toString();
        s = dataSnapshot.getKey();
        list.add(ss);

        barkodlist.add(s);

        count++;
        if(count >= dataSnapshot.getChildrenCount()){
            //stop progress bar here
            count = 0;
            adapter();
        }
    }

回答1:


If your database looks like:

medics:
    <RANDOM_UUID>:
        medicname: "Some value"

Then you should query using

dref = FirebaseDatabase.getInstance().getReference().child("medics").orderByChild("medicname");
dref.addChildEventListener(new ChildEventListener() { ... });

Ignore the UUID if you're querying childs using orderByChild.



来源:https://stackoverflow.com/questions/47803870/firebase-how-to-use-orderbychild

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