I'm putting together a very simplistic project in which I display the processes that are running on android and compare them to a list in a txt file that has other processes. The intent is to verify that all processes that are appearing in the textView are in the txt. If something appears in the textView and this is not in TXT, send an alert showing what is in the textView and not in txt. I thought of a solution using arraylist
1 - in the textview, the output is like this
com.whatsapp
com.snaptube.premium
com.youtube
com.facebook
separated by a line break
My text file is the same, but with more processes. Example
com.whatsapp
com.snaptube.premium
com.youtube
com.facebook
com.outroApp
The purpose of the textview is to use texview some application that is not in txt and the user will receive a warning that the application is not in txt. it would be as if each line of the textview were compared to all lines of the text file. For that I thought of 2 for's
What I have now:
ArrayList<String> texto = new ArrayList<String>(); // array para salvar o que esta no arquivo texto
ArrayList<String> textView= new ArrayList<String>(); // array para salvar o que mostra no textview
while ( (recebe_string = bufferedReader.readLine()) != null ) {
texto.add(recebe_string); // adiciono o que tenho no txt em um array
while ((line = reader.readLine()) != null) { // exibindo no textview
textView.add(parteFinal); //adiciono os processos que estao no textview em um array
Now comes the part that I can not. Make comparison of what it has in textview with txt
I thought about it
for (int i = 0; i < texto.size() ;i++) { // percorro array do txt
for (int ii = 0; ii <textView.size() ; ii++) { // percorro array do textview
if (textView.get(ii).equals(texto.get(i))) // se tudo que tem no textview tem no txt nada a fazer
teste = false;
else{ // se tem algo no textView que nao tem no txt, avisa
teste = true;
virus = textView.get(ii); // capturo o que tem no textview e nao tem no txt
System.out.println("virus"+ textView.get(ii)); // exibo o que capturei
}
}
}
I'm having a hard time comparing. this method I did it even warns that the process displayed in the textView is in txt