Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 查找数据库结构中的子节点数_Java_Android_Firebase_Firebase Realtime Database - Fatal编程技术网

Java 查找数据库结构中的子节点数

Java 查找数据库结构中的子节点数,java,android,firebase,firebase-realtime-database,Java,Android,Firebase,Firebase Realtime Database,大家好,有没有办法计算firebase中的儿童数量 我有一个这样的数据库结构 Testitem1{ test: "" }, Testitem2{ test: "" } 我只想计算Testitem节点 对firebase实时数据库中的子节点进行计数 FirebaseDatabase database = FirebaseDatabase.getInstance(); // get the reference of child containing testitems DatabaseRefere

大家好,有没有办法计算firebase中的儿童数量

我有一个这样的数据库结构

Testitem1{
test: ""
},
Testitem2{
test: ""
}
我只想计算Testitem节点


对firebase实时数据库中的子节点进行计数

FirebaseDatabase database = FirebaseDatabase.getInstance(); // get the reference of child containing testitems
DatabaseReference myRef = database.getReference();

myRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
    for (DataSnapshot snap: dataSnapshot.getChildren()) {
        Log.e(snap.getKey(),snap.getChildrenCount() + "");
    }
}

@Override
public void onCancelled(DatabaseError databaseError) {

}
});