I am getting DB values with following code:
public List<String> getPlayerNames() {
List<String> playerNames = new ArrayList<String>();
c = myDataBase.rawQuery("SELECT * FROM PLAYERS",null);
while (c.moveToNext()) {
String q = c.getString(1);
playerNames.add(q);
}
c.close();
myDataBase.close();
return playerNames;
}
I now want to compare the items in this List to a String value with following method:
private boolean checkIfExists(String newPlayer) {
// TODO Auto-generated method stub
List<String> playerNames = myDbHelper.getPlayerNames();
//here a loop?!
return false;
}
But I don’t really know how to compare these list items with a string value. I tried with a for loop, but then again, a list doesn’t support a .length() method to go trough all elements? Tnx!
1 Answer