Retrieve the amount of children that have a node

1

How do I retrieve the amount of children I have in a node?

I already have the correct path, I just need to know how I can tell the children of this node.

private DatabaseReference qtdeFilRef;    
qtdeFilhosRef.child("primeiroNo").child("segundoNo");

Does anyone know how to recover children from "secondNo"?

    
asked by anonymous 21.09.2018 / 13:57

1 answer

0

Your question has already been answered.

a>

I tested here and this code below was the one that answered me the most.

DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference yourRef = rootRef.child("Authenticated-Users");
ValueEventListener eventListener = new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        int count = 0;
        for(DataSnapshot ds : dataSnapshot.getChildren()) {
            count = count + 1;
        }
        Log.d("TAG", count + "");
    }

    @Override
    public void onCancelled(DatabaseError databaseError) {}
};
yourRef.addListenerForSingleValueEvent(eventListener);
    
23.09.2018 / 20:08