伙计我开发了一款小游戏,我想在同一个屏幕上保存高分。
我认为保存整数很容易,但问题是我不知道从哪里开始可以任何人指导我,如果你想我可以给你我的代码
答案 0 :(得分:2)
SharedPreferences sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
保存数据
Editor editor = sharedpreferences.edit();
editor.putInt("key", your score goes here);
editor.commit();
而不是重新取回你的分数
SharedPreferences sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
int highScore = sharedpreferences.getInt("key" , defaultValue);
你去了