import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
public class PreferenceSetting {
private String PREF_VALUE = "pref_value";
private static PreferenceSetting store;
SharedPreferences pref;
public static PreferenceSetting getInstance(Context context) {
if (store == null)
store = new PreferenceSetting(context);
return store;
}
private PreferenceSetting(Context context) {
pref = PreferenceManager.getDefaultSharedPreferences(context);
}
public void setValue(String value) {
pref.edit().putString(PREF_VALUE, value).commit();
}
public String getValue() {
return pref.getString(PREF_VALUE, "-");
}
}
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
public class PreferenceSetting {
private String PREF_VALUE = "pref_value";
private static PreferenceSetting store;
SharedPreferences pref;
public static PreferenceSetting getInstance(Context context) {
if (store == null)
store = new PreferenceSetting(context);
return store;
}
private PreferenceSetting(Context context) {
pref = PreferenceManager.getDefaultSharedPreferences(context);
}
public void setValue(String value) {
pref.edit().putString(PREF_VALUE, value).commit();
}
public String getValue() {
return pref.getString(PREF_VALUE, "-");
}
}
No comments:
Post a Comment