當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。