0
请帮助..我堆积与我的论文.. 在这里我使用共享首选项,它适用于2活动之间。但是,我想保留可用于多项活动的数据。我怎么做?共享首选项可用于所有活动
的方式,我保存:
SharedPreferences example = getSharedPreferences(GAME_PREFERENCES_LOGIN, 0);
Editor editor = example.edit();
editor.putString("username", username.getText().toString());
editor.commit();
,我检索方式:
SharedPreferences example = getSharedPreferences(GAME_PREFERENCES_LOGIN, 0);
String userString = example.getString("username", "null");
tv.setText("Welcome " +userString);
我怎样才能获得从其他活动和其他活动这个值,而不必一次又一次地拯救这个单一的价值? 谢谢!