I am trying to create a function that that checks if a level is held within an SQLite database. If it is, and the new score is greater than the score in the table then I want to edit it. I have created an edit function that seems to work fine and an add to database function that is called when the level being checked doesn't exist.
Here is my function
void isHighScore(String level, int score) {
List<String> scores = getHighScore();
List<String> levels = getHighScoreLevel();
for (int i = 0; i < levels.size(); i++) {
int scoreVal = Integer.parseInt(scores.get(i));
String levelVal = levels.get(i).toString();
if (levelVal == level && scoreVal < score) {
try {
editScore(level, score);
} catch (Exception e) {}
}
}
if (!levels.contains(level)) {
createHighScoreEntry(level, score);
}
}
So far, only the create entry function is working, so my main problem resides in the for loop. Any help will be greatly appreciated.