I'm having trouble picking up data that apparently did not have any complications, the question is I want to collect the Yes and No of the objects I get and I'm not able to
I leave the code
database.getReference("Events").child( code ).child( "Users" ).addValueEventListener( new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
int cont = 0; int si=0; int no=0; int mb=0;
// String Si="Si",No="No";
String hola;
for (DataSnapshot snapshot: dataSnapshot.getChildren()){
User user = snapshot.getValue(User.class);
data.add( user);
hola = data.get( 0 ).getvote();
if(hola.equals( "Si" )){
si++;
}
if (hola.equals( "No" )){
no++;
}
if(hola.equals( null )){
mb++;
}
cont++;
}
participantes = data.size();// Total participantes
String participantesCast= Integer.toString( participantes );
tvTotalParticipantes.setText( participantesCast );
Log.i("Si","Si"+si);
Log.i("No","No"+no);
Log.i("mb","mb"+mb);
/// Log.i("mb","mb"+hola);
}
In the debug everything goes to the Si and the Mb and I do not understand what I'm doing wrong because I've tried it in several ways without coming up with the good one
I add User class public class User {
private String name;
private String email;
private String avatar;
private List<String> events;
private String vote;