下面是代码:
package com.androidbook.triviaquiz;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
public class QuizActivity extends Activity {
/** Called when the activity is first created. */
public static final String GAME_PREFERENCES="GamePrefs";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.game);
SharedPreferences settings=getSharedPreferences(GAME_PREFERENCES,MODE_PRIVATE);
SharedPreferences.Editor prefEditor=settings.edit();
prefEditor.putString(“UserName”,“JaneDoe”);
prefEditor.putInt(“UserAge”,22);
prefEditor.commit();
}
}
在tokens.delete上获取'tokens'上的'语法错误'@ putString和'tokens参数列表中的'语法错误,而不是'@ putInt。 在eclipse中编程。 感谢。