my firebasebase database structure
I created one android application in this application, I want to count unique child value.
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).
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) {