private void readDataBaseContent() { // TODO DATABASE db = new DatabaseHandler(this); HS = new Highscore[20]; if (db.getCount() > 0) { for (int i = 0; i < 20; i++) HS[i] = db.getHighscore(i); } }
protected void addScore() { String name = "Empty"; int max; Highscore temp; if (HS[4 + LM].getScore() < score) { HS[4 + LM].setScore(score); if ((name = etw.getText().toString()) != "") HS[4 + LM].setName(name); else HS[4 + LM].setName("Empty"); // Sort for (int i = LM; i < LM + 5; i++) { max = i; for (int j = i + 1; j < LM + 5; j++) { if (HS[max].getScore() < HS[j].getScore()) { max = j; } } temp = HS[i]; HS[i] = HS[max]; HS[max] = temp; } for (int i = 0; i < 20; i++) db.replaceHighscore(HS[i], i); } }