Comparing data returned from BD

Asked

Viewed 90 times

0

I have a problem which is this::

When reading the data from a given Firebase node, I get an undetermined String number. The name of each String, is the ID of the User. When returning this data, save them in a ArrayList, to compare whether Uid X is on the list like this: arrayList.contains("Uid X").

However, the return I have is a true or a false for each of the Strings. How to make return only a true, or a false after checking every list?

  • At first it would just move all the code into one if, No? I suggest you post snippets of your code - blindly makes it harder for staff to respond!

  • 1

    Enjoy and tour, and see more information on how to ask here.

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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.