I'm making a simple memory game in Android studio. The game contains 2 activities (MainActivity, GameActivity) I need to save the high score from the GameActivity and show it in the MainActivity. I've already attempted using SharedPreferences but the high score remains 0 in the MainActivity.
Here is the code i have in the GameActivity:

```
SharedPreferences prefs;
SharedPreferences.Editor editor;
String dataName = "MyData";
String intName = "MyInt";
int defaultInt = 0;
int hiScore;

prefs = getSharedPreferences(dataName,MODE_PRIVATE);
editor = prefs.edit();
hiScore = prefs.getInt(intName, defaultInt);
editor.putInt(intName, hiScore);
editor.commit();

```

the code in the MainActivity:

```
SharedPreferences prefs;
String dataName = "MyData";
String intName = "MyString";
int defaultInt = 0;
public static int hiScore;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    prefs = getSharedPreferences(dataName,MODE_PRIVATE);
    hiScore = prefs.getInt(intName, defaultInt);
    TextView textHiScore =(TextView) findViewById(R.id.textHiScore);
    textHiScore.setText("Hi: "+ hiScore);
}

```