title: How to count number of particular child occurrence in firebase for Android in Java
body: <p>I am making an attendance app and I need to count the particular student attendance from the Firebase. I need to count the number of <strong>"prof"</strong> occurrence and I am new to this.</p>
  
  <p><a href="https://i.stack.imgur.com/Gdd7K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gdd7K.png" alt="enter image description here"></a></p>
  
  <pre><code> DatabaseReference attendance = FirebaseDatabase.getInstance().getReference("Attendance");
      attendance.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
              for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
                  totaldays++; // total class days
                  if(snapshot.child("name").getValue(String.class).equals("prof")){
                      //count no of days present
                  }
                  Log.e(snapshot.getKey(), snapshot.getChildrenCount() + "");
              }
              Log.e(TAG, totaldays + "");
          }
          @Override
          public void onCancelled(@NonNull DatabaseError databaseError) {}
      }); 
  </code></pre>
  
  <p>But the result is showing <code>null</code> value.</p>