/** * 获得最高分 * * @param mode * @return */ public int get(int mode) { if (mode == 1) { return games1.get(); } if (mode == 2) { return games2.get(); } return 12345; }
/** * 刷新最高分 * * @param mode * @param score */ public void refresh(int mode, int score) { if (mode == 1) { if (score >= games1.get()) games1 = new SafeInt(score); SaveData(); } if (mode == 2) { if (score >= games2.get()) games2 = new SafeInt(score); SaveData(); } }
/** 保存数据 */ public void SaveData() { sp.edit().putInt(game1, games1.get()).commit(); sp.edit().putInt(game2, games2.get()).commit(); }