[英]count the nodes of a child in the firebase
final long count;
DatabaseReference ref = FirebaseDatabase.getInstance().getReference();
ref.child("postagens-curtidas").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
count = dataSnapshot.getChildrenCount();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
这是获得子节点总数的方法。
假设您具有保存qtdCurtidas的密钥。 您可以将其保存如下
ref.child("postagens-curtidas").child("Your Key Here").child("qtdCurtidas").setValue(count);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.