I have some code that collects a number, I am able to prove that I am genuating a number will im doing this but when I go to save the number using this code
public void SaveScore()
{
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("Score", (StringScore));
}
Then I call it back later in another page with this code
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
ScoreString = (settings.getString("Score", "0"));
Score.setText(ScoreString + "%");
It comes up as 0 I know that it is the default number so why am I not saving the number?
You’ve forgotten to do an
editor.commit()to commit your changes.