After adding these lines, the application stopped running and the phone shows that there is a threat
Preservation
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putInt("best_score", score); editor.commit(); Loading
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); if (sharedPreferences.contains("best_score")) { // we have a high score saved, load it... int bestscore = sharedPreferences.getInt("best_score", -1); scores.setText("Лучший : " + bestscore); // here you'd like to do something with the value, for example display it. } else { scores.setText("Лучший : 0"); // there is no high score value - you should probably hide the "best score" TextView } UPD: checked-checked and noticed that as soon as I add the line SharedPreferences.Editor editor = sharedPreferences.edit(); immediately the application stops running