Below is an example of code to count by rank and total:
final FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference ref = database.getReference("usuario");
ref.addListenerForSingleValueEvent(new ValueEventListener() {
public void onDataChange(DataSnapshot dataSnapshot) {
HashMap<String, Integer> map = new HashMap<>();
int mTotal=0;
for (DataSnapshot snap : dataSnapshot.getChildren()) {
String mUserKey = snap.getKey();
if (snap.child("ocorrencia").exists()) {
map.put(mUserKey, (int) snap.child("ocorrencia").getChildrenCount());
}
}
for (Map.Entry<String,Integer> entry : map.entrySet()) {
System.out.printf("%s -> %s%n", entry.getKey(), entry.getValue());
mTotal = mTotal + entry.getValue();
}
System.out.printf("Somatória total de ocorrências: %s%n", mTotal);
}
@Override
public void onCancelled(DatabaseError databaseError) {}
});