I've been able to save scores from previous sessions with sharedpreferences, however I haven't been able to resume counting from the last saved int
public class GameDisplay extends AppCompatActivity {
public int scoreX, xpCount;
private TextView Xcounter, xpcount;
@Override
protected void onResume(){
super.onResume();
SharedPreferences sp = getSharedPreferences("MySharedPrefs", MODE_PRIVATE);
int xscore = sp.getInt("Xcount", 0);
int xpi = sp.getInt("xp", 0000);
Xcounter.setText(String.valueOf(xscore));
xpcount.setText(String.valueOf(xpi));
scoreX = Integer.parseInt(String.valueOf(xscore));
xpCount = Integer.parseInt(String.valueOf(xpi));
}
private void performAction(ImageView imageView, int selectedBoxPosition){
if (checkPlayerWin()){
scoreX++;
Xcounter.setText(""+scoreX);
xpCount++;
xpcount.setText("000"+(5*xpCount))
}else (totalSelectedBoxes == 9){}
@Override
protected void onPause() {
super.onPause();
SharedPreferences sharedPreferences = getSharedPreferences("MySharedPref",MODE_PRIVATE);
SharedPreferences.Editor myEdit = sharedPreferences.edit();
myEdit.putInt("Xcount", Integer.parseInt(Xcounter.getText().toString()));
myEdit.putInt("xp", Integer.parseInt(xpcount.getText().toString()));
myEdit.apply();
}
}