本文整理匯總了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();
}