本文整理汇总了Java中android.content.SharedPreferences.Editor.commit方法的典型用法代码示例。如果您正苦于以下问题:Java Editor.commit方法的具体用法?Java Editor.commit怎么用?Java Editor.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.SharedPreferences.Editor
的用法示例。
在下文中一共展示了Editor.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupSampling
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private void setupSampling() {
SharedPreferences preferences = this.context.getSharedPreferences(PREFERENCES_FILE_NAME, Context.MODE_PRIVATE);
if (preferences.getInt(PREFERENCE_KEY_SAMPLING_RATE, 0) == this.samplingRate) {
this.isSampling = preferences.getBoolean(PREFERENCE_KEY_IS_SAMPLING, true);
}
else {
this.isSampling = (this.samplingRate <= 0 || new Random().nextInt(this.samplingRate) == 0);
Editor editor = preferences.edit();
editor.putBoolean(PREFERENCE_KEY_IS_SAMPLING, this.isSampling);
editor.putInt(PREFERENCE_KEY_SAMPLING_RATE, this.samplingRate);
editor.commit();
}
this.log("isSampling = " + this.isSampling + ", samplingRate = " + this.samplingRate);
}
示例2: initData
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private void initData() {
this.mContext = this;
this.jsObject = new JSObject(this.mContext);
SharedPreferences sharedPreferences = getSharedPreferences("lemallsdk", 0);
LemallPlatform.getInstance().uuid = sharedPreferences.getString("lemall_sdk_uuid", "");
Bundle extras = getIntent().getExtras();
if (extras != null) {
this.buyByWatching = extras.getBoolean(Constants.BUY_BY_WATCHING);
this.pageFlag = extras.getString(Constants.PAGE_FLAG);
this.value = extras.getString(Constants.VALUE_ID);
String in_uuid = extras.getString(Constants.UUID);
if (!TextUtils.isEmpty(this.pageFlag)) {
if (this.buyByWatching) {
if (!in_uuid.equals(LemallPlatform.getInstance().uuid)) {
LemallPlatform.getInstance().uuid = in_uuid;
}
Editor editor = sharedPreferences.edit();
editor.putString("lemall_sdk_uuid", LemallPlatform.getInstance().uuid);
editor.commit();
}
if (!"other".equals(this.pageFlag)) {
getWebUrl();
}
}
}
}
示例3: putAllBoolean
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**设置所有boolean
* @param values
*/
public static void putAllBoolean(boolean[] values){
if (values == null || values.length != KEYS.length) {
Log.e(TAG, "putAllBoolean values == null || values.length != KEYS.length >> return;");
return;
}
Editor editor = context.getSharedPreferences(APP_SETTING, Context.MODE_PRIVATE).edit();
editor.clear();
for (int i = 0; i < values.length; i++) {
editor.putBoolean(KEYS[i], values[i]);
}
editor.commit();
init(context);
}
示例4: writeData
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static synchronized void writeData(String key, String valus) {
synchronized (SharedPreferencesUtil.class) {
if (mSharePreferences == null) {
mSharePreferences = getContext().getSharedPreferences(LEBOX_TABLE, 0);
}
if (needWriteData(key, valus)) {
Editor editor = mSharePreferences.edit();
editor.putString(key, valus);
editor.commit();
}
}
}
示例5: saveChannelBySharedPreferences
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* 本地保存channel & 对应版本号
* @param context
* @param channel
*/
private static void saveChannelBySharedPreferences(Context context, String channel){
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
Editor editor = sp.edit();
editor.putString(CHANNEL_KEY, channel);
editor.putInt(CHANNEL_VERSION_KEY, getVersionCode(context));
editor.commit();
}
示例6: saveLatestLaunchTime
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public boolean saveLatestLaunchTime() {
long t = System.currentTimeMillis();
String date = StringUtils.timeString(t);
String minutes = StringUtils.timeStringByMinutes(t);
SharedPreferences sp = context.getSharedPreferences(FORCE_ALERT, 0);
if (sp.getLong(PREF_CURRENTTIMEMILLIS, 0) != 0 && t - sp.getLong(PREF_CURRENTTIMEMILLIS, 0) < 300000) {
return false;
}
Editor editor = sp.edit();
editor.putLong(PREF_CURRENTTIMEMILLIS, t);
editor.putString(PREF_LAUNCH_DATE, date);
editor.putString(PREF_LAUNCH_MINUTE, minutes);
editor.commit();
return true;
}
示例7: onBuildFinish
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
@Override
public void onBuildFinish(String grammarId, SpeechError error) {
if(error == null){
String grammarID = new String(grammarId);
Editor editor = mSharedPreferences.edit();
if(!TextUtils.isEmpty(grammarId))
editor.putString(KEY_GRAMMAR_ABNF_ID, grammarID);
editor.commit();
showTip("语法构建成功:" + grammarId);
}else{
showTip("语法构建失败,错误码:" + error.getErrorCode());
}
}
示例8: setPreferenceFloatValue
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* Set a preference float value
* @param key the preference key to set
* @param value the value for this key
*/
public void setPreferenceFloatValue(String key, float value) {
if(sharedEditor == null) {
Editor editor = prefs.edit();
editor.putFloat(key, value);
editor.commit();
}else {
sharedEditor.putFloat(key, value);
}
}
示例9: saveQZoneLogin
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void saveQZoneLogin(String openid, String access_token, String expires_in) {
Editor editor = context.getSharedPreferences("qzone", 0).edit();
editor.putString("openid", openid);
editor.putString("access_token", access_token);
editor.putString("expires_in", expires_in);
editor.commit();
}
示例10: setEnable
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void setEnable(boolean b, Context context) {
Editor edit = context.getSharedPreferences(TAG, 0).edit();
edit.putBoolean("ObserverEnable", b);
edit.commit();
if (!b) {
stop(context);
}
}
示例11: setLeMallShow
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void setLeMallShow(boolean isShow) {
Editor editor = context.getSharedPreferences(SETTINGS, 4).edit();
editor.putBoolean("isLeMallShow", isShow);
editor.commit();
}
示例12: clearPreference
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void clearPreference(Context context, String preference) {
SharedPreferences sharedPreferences = context.getSharedPreferences(preference, Context.MODE_PRIVATE);
Editor editor = sharedPreferences.edit();
editor.clear();
editor.commit();
}
示例13: a
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void a(String str, String str2) {
Editor edit = this.b.edit();
edit.putString(str, str2);
edit.commit();
}
示例14: setFirstInboxMessageAdded
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void setFirstInboxMessageAdded(boolean firstInboxMessageAdded) {
Editor editor = PreferenceManager.getDefaultSharedPreferences(this.context).edit();
editor.putBoolean("first_inbox_entry_added", firstInboxMessageAdded);
editor.commit();
}
示例15: putLong
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void putLong(String str, Long l) {
Editor edit = this.prefrence.edit();
edit.putLong(str, l.longValue());
edit.commit();
}