Recently I am developing a simple android game. For the scoring part, I have on many websites that shared preferences are best to save the high score. Now, what if I need to sav
score setting
static final String[] LEVEL = {"level1","level2","level3"};
int bestScore1 = 100;
int bestScore2 = 90;
int bestScore3 = 80;
SharedPreferences sp = getSharedPreferences(LEVEL[0],Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putInt("First", bestScore1);
editor.putInt("Second", bestScore2);
editor.putInt("Third", bestScore3);
editor.commit();
but you need to count LEVEL's index
score getting
SharedPreferences sp = getSharedPreferences(LEVEL[0], Activity.MODE_PRIVATE);
bestScore1 = sp.getInt("First", 0);
bestScore2 = sp.getInt("Second", 0);
bestScore3 = sp.getInt("Third", 0);
hmm.. but I think it is not best way for your question :<