在第一个(MainActivity)中,我通过 SharedPreferences 保存数据:
Editor editor = mGameSettings.edit();
editor.putString(GAME_PREFERENCES_SHOP, Shops.get(lv.getCheckedItemPosition()));
editor.commit();
我可以在重新启动应用程序后从 MainActivity 读取这些数据:
if (mGameSettings.contains(GAME_PREFERENCES_SHOP))
Tv2.setText(mGameSettings.getString(GAME_PREFERENCES_SHOP, ""));
但是如何从其他活动中读取和编辑此 SharedPreferences 呢?