我希望保存一些变量,当我关闭我的应用并在打开应用后加载它们(对于游戏中的统计信息)
我该怎么做?
编辑:这是我的代码:
TextView test1;
String punkte = "15";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SharedPreferences save = getSharedPreferences(punkte, 0);
save.edit().putString("score", punkte);
SharedPreferences load = getSharedPreferences(punkte, 0);
String points = load.getString("score", "0");
test1 = (TextView) findViewById(R.id.test1);
test1.setText(points);
}