Preferences

public class Preferences {
	private String CONFIG_NAME = "pref";
	private SharedPreferences spf;
	private Editor editor;
	private Context mContext;
	
	public Preferences(Context context) {
		this.mContext = context;
		spf = context.getSharedPreferences(CONFIG_NAME, 0);
		editor= spf.edit();
	}
	
	public boolean getShowData(){
		return spf.getBoolean("show_data", false);
	}
	
	public void setShowData(boolean b){
		editor.putBoolean("show_data", b);
		editor.commit();
	}
}

 

你可能感兴趣的:(preferences)