当前位置: 首页>>代码示例>>Java>>正文


Java Editor.commit方法代码示例

本文整理汇总了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);
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:17,代码来源:Core.java

示例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();
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:27,代码来源:LemallSdkMainActivity.java

示例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);
}
 
开发者ID:TommyLemon,项目名称:APIJSON-Android-RxJava,代码行数:19,代码来源:SettingUtil.java

示例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();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:13,代码来源:SharedPreferencesUtil.java

示例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();
}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:13,代码来源:ChannelUtil.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:16,代码来源:PreferencesManager.java

示例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());
	}			
}
 
开发者ID:SoulEaterVTT,项目名称:KotlinStudy,代码行数:14,代码来源:AsrDemo.java

示例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);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:15,代码来源:PreferencesWrapper.java

示例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();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:8,代码来源:PreferencesManager.java

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:UninstalledObserver.java

示例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();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:6,代码来源:PreferencesManager.java

示例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();
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:7,代码来源:PreferencesUtils.java

示例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();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:6,代码来源:c.java

示例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();
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:6,代码来源:Settings.java

示例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();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:6,代码来源:SharePrefrenceHelper.java


注:本文中的android.content.SharedPreferences.Editor.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。