我正在24 小时内为 Sams Android Development学习 Android 开发。我正在实现一个名为 theredone 的游戏,其中包含以下活动:
quizactivity
, splashactivity
, gameactivity
, menuactivity
, settingsactivity
, helpactivity
. splashactivity
延伸quizactivity
而quizactivity
延伸Activity
。
我SharedPreferences
在quizactivity.java
.
package com.androidbook.triviaquiz6;
import android.app.Activity;
import android.content.SharedPreferences;
public class QuizActivity extends Activity {
public static final String GAME_PREFERENCES = "GamePrefs";
private SharedPreferences myPrefs; //Syntax error on token ";", { expected after this token -//----------------------------
myPrefs = Actionactivity.this.getSharedPreferences("myPrefs", MODE_WORLD_WRITEABLE);
SharedPreferences.Editor prefsEditor = myPrefs.edit();
prefsEditor.putString("key name", "key valuse");
prefsEditor.commit();
//this one to read data
myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
myPrefs.getString("key name", "") ;
}//Syntax error, insert "}" to complete ClassBody -----------------------
你能帮我吗?我不认为这是一个愚蠢的qs