// I declared myPrefs globally in the lass
SharedPreferences myPrefs = null;
// this is called in my do draw function
public void doDraw() {
}聲明SharedPreferences.Editor崩潰我的應用程序
myPrefs = this.getSharedPreferences("myPrefs", Context.MODE_WORLD_READABLE); SharedPreferences.Editor editor = myPrefs.edit();
editor.putInt("MYHIGHSCORE", score); editor.commit();
每當我打電話SharedPreferences.Editor editor = myPrefs.edit();
,我的程序崩潰。我做錯了什麼?我正在嘗試爲高分系統存儲一個int。並且SharedPreferences
對於像我這樣的迷你高分系統提出了很多建議。
什麼是錯誤信息? –
@LawrenceChoy對日誌貓說它有一個空指針異常。 – CtheW
是你的活動類裏面的繪製函數嗎? –