Hi, I have a problem with Firebase, I'm creating an app that is like a data capture application where the user clicks on YES or NO and I have to make a statistical chart of how many of them have SI in different fields such as Comment, Plane ,etc. but since the user can edit some fields within the package (for example, edit the "Comment" field to a "NO"), another package of C1 code would be created with a "NO" in "comment" but the previous package would still be had the "Yes" in his "comment" and I at the time of doing the statistical graph would have to use the last value entered and then the Firebase read me all data regardless of whether it is repeated or not and would give me wrong data
I made a for cycle so I could go through all the fields but I do not know how to remove the repeated ones. Thank you
Query query = FirebaseDatabase.getInstance().getReference("Usuario").orderByChild("Comentario").equalTo("Si");
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
cnt = 0;
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
String value = snapshot.getValue().toString();
tv.setText(value);
if (value.contains("Codigo=C")) {
NcomentariosC++;
}
if (value.contains("Codigo=V")) {
NcomentariosV++;
}
if (value.contains("Codigo=P")) {
NcomentariosP++;
}
cnt++;
}
Intent intento = new Intent(getApplicationContext(), DataGraficos.class);
intento.putExtra("NcomentCol", NcomentariosCol);
intento.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(intento);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});