title: How to count child-node Integer values in Firebase database?(please see the image , Thank you)
body: <p><a href="https://i.stack.imgur.com/IrQny.png" rel="nofollow noreferrer">my firebasebase database structure</a><img src="https://i.stack.imgur.com/k4ILG.png" alt=""></p>
  
  <p>I created one android application in this application, I want to count unique child value.</p>
  
  <p>I created for loop inside the database reference and assign global variable but the thing is I don't know how many unique values will become to my calculation(HOw many variables).</p>
  
  <pre><code>dbcloud.addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
      for(DataSnapshot dataSnapshot1:dataSnapshot.getChildren())
      {
          Modelfortotalsoldcount mc=dataSnapshot1.getValue(Modelfortotalsoldcount.class);
          String name=mc.getFoodname();
          String qty=mc.getFoodqty();
          String price=mc.getFoodprice();
          int totalcount=0;
          if(fname.equals(name))
          {
              String fgname=name;
              String fgprice=price;
              Integer intqty=Integer.valueOf(qty);
              totalcount=totalcount+intqty;
              String totalval=String.valueOf(totalcount);
          }
      }
    }
    @Override
    public void onCancelled(@NonNull DatabaseError databaseError) {
  </code></pre>