如何使用查询从Firebase检索嵌套子项列表?

时间:2017-11-06 16:44:14

标签: android firebase firebase-realtime-database

我正在尝试从使用Firebase查询的子项列表中检索但是失败。我的代码。我的logcat每次都得到0,这意味着datasnapshot.getchildren什么都不返回。如何修复它?我分享我的数据库截图。

 Query queryRef = databaseReference.child("Class").orderByChild("name").equalTo(contactofSA.getName());
    queryRef.getRef().child("Student").addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            final ArrayList<student> studentListFromServer=new ArrayList<student>();
          if (dataSnapshot.getChildrenCount()==0){
              Log.d("GK","0");
          }
            for(DataSnapshot StudentData:dataSnapshot.getChildren()){

                student student=new student();
                student=StudentData.getValue(student.class);
                studentListFromServer.add(student);
            }

            studentActivity.studentList=new ArrayList<>();
            studentActivity.studentList=studentListFromServer;
            studentListAdapter.addAll(studentList);
            studentItems.setAdapter(studentListAdapter);
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

I actually want to get this red marked child

0 个答案:

没有答案
相关问题