Comparing data returned from DB

0

I have a problem that is as follows:

When reading data from a particular Firebase node, I get an indefinite number of Strings. The name of each String , is ID of User. When returning this data, save it in ArrayList , to compare if Uid X is in the list, like this: arrayList.contains("Uid X") .

However, the return I get is a true or a false for each of Strings . How do I return only a true, or a false after checking the entire list?

    
asked by anonymous 24.05.2017 / 05:34

1 answer

0

Just use one cycle:

boolean estaNaLista = false;
for(int i=0; i < arrayList.size();i++)
  if(arrayList.get(0).equalsIgnoreCase("Uid X"))
  {
    estaNaLista = true;
    break;
  }
//A este ponto o estaNaLista tera o valor que voce pretende.
    
08.06.2017 / 23:39