android.content.SharedPreferences.Editor#putBoolean ( )源码实例Demo

下面列出了android.content.SharedPreferences.Editor#putBoolean ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FastLib   文件: SPUtil.java
/**
 * 存放object
 *
 * @param context
 * @param fileName
 * @param key
 * @param object
 * @return
 */
public static boolean put(Context context, String fileName, String key, Object object) {
    SharedPreferences sp = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    Editor editor = sp.edit();
    if (object instanceof String) {
        editor.putString(key, (String) object);
    } else if (object instanceof Integer) {
        editor.putInt(key, ((Integer) object).intValue());
    } else if (object instanceof Boolean) {
        editor.putBoolean(key, ((Boolean) object).booleanValue());
    } else if (object instanceof Float) {
        editor.putFloat(key, ((Float) object).floatValue());
    } else if (object instanceof Long) {
        editor.putLong(key, ((Long) object).longValue());
    } else if (object instanceof Set) {
        editor.putStringSet(key, (Set<String>) object);
    } else {
        editor.putStringSet(key, (Set<String>) object);
    }
    return editor.commit();
}
 
源代码2 项目: JianDan   文件: SharedPreUtils.java
public static void setBoolean(Context context, String key, boolean value) {
	SharedPreferences sp = context.getSharedPreferences(
			SHARED_PREFERANCE_NAME, Context.MODE_PRIVATE);
	Editor editor = sp.edit();
	editor.putBoolean(key, value);
	editor.commit();
}
 
源代码3 项目: PhoneProfilesPlus   文件: EventPreferencesSMS.java
void loadSharedPreferences(SharedPreferences preferences)
{
    Editor editor = preferences.edit();
    editor.putBoolean(PREF_EVENT_SMS_ENABLED, _enabled);
    //editor.putString(PREF_EVENT_SMS_EVENT, String.valueOf(this._smsEvent));
    editor.putString(PREF_EVENT_SMS_CONTACTS, this._contacts);
    editor.putString(PREF_EVENT_SMS_CONTACT_GROUPS, this._contactGroups);
    editor.putString(PREF_EVENT_SMS_CONTACT_LIST_TYPE, String.valueOf(this._contactListType));
    editor.putBoolean(PREF_EVENT_SMS_PERMANENT_RUN, this._permanentRun);
    editor.putString(PREF_EVENT_SMS_DURATION, String.valueOf(this._duration));
    editor.apply();
}
 
源代码4 项目: product-emm   文件: Preference.java
/**
 * Put boolean data to shared preferences in private mode.
 * @param context - The context of activity which is requesting to put data.
 * @param key     - Used to identify the value.
 * @param value   - The actual value to be saved.
 */
public static void putBoolean(Context context, String key, boolean value) {
	SharedPreferences mainPref =
			context.getSharedPreferences(context.getResources()
					                             .getString(R.string.shared_pref_package),
			                             Context.MODE_PRIVATE
			);
	Editor editor = mainPref.edit();
	editor.putBoolean(key, value);
	editor.commit();
}
 
源代码5 项目: letv   文件: PreferencesManager.java
public void setGameShow(boolean isShow) {
    Editor editor = context.getSharedPreferences(SETTINGS, 4).edit();
    editor.putBoolean("isGameShow", isShow);
    if (LetvUtils.isSpecialChannel()) {
        editor.putBoolean("isGameShow", false);
    }
    editor.commit();
}
 
源代码6 项目: HeroVideo-master   文件: PreferenceUtil.java
public static void putBoolean(String key, boolean value)
{

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(HeroVideoApp.getInstance());
    Editor editor = sharedPreferences.edit();
    editor.putBoolean(key, value);
    editor.apply();
}
 
源代码7 项目: product-emm   文件: NetworkConnectedReceiver.java
@Override
public void onReceive(Context context, Intent intent) {

    Log.d(TAG, "Entered OnReceive in NetworkConnectedReceiver");

    //Skipping non admin users
    if (ActivityManager.getCurrentUser() != 0) {
        Log.i(TAG, "The user serial number is " + ActivityManager.getCurrentUser());
    } else {
        Log.i(TAG, "The user is admin");
        SharedPreferences prefs = context.getSharedPreferences(EMM_PREFERENCES, Context.MODE_PRIVATE);
        Boolean isAgentCalled = prefs.getBoolean(EMM_AGENT_HAS_BEEN_CALLED, false);

        if (!isAgentCalled) {
            //Check network connected
            if (isConnected(context)) {
                Intent agentLauncherIntent = new Intent();
                agentLauncherIntent.setComponent(new ComponentName(Constants.AGENT_APP_PACKAGE_NAME,
                                                                   Constants.AGENT_APP_PACKAGE_NAME + Constants.AGENT_APP_LAUNCH_ACTIVITY));
                agentLauncherIntent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                agentLauncherIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(agentLauncherIntent);

                Editor editor = prefs.edit();
                editor.putBoolean(EMM_AGENT_HAS_BEEN_CALLED, true);
                editor.apply();
                Log.i(TAG, "EMM agent has been called");
            }
        }
    }
}
 
源代码8 项目: PS4-Payload-Sender-Android   文件: Prefs.java
/**
 * @param key   The name of the preference to modify.
 * @param value The new value for the preference.
 * @see Editor#putBoolean(String, boolean)
 */
public static void putBoolean(final String key, final boolean value) {
    final Editor editor = getPreferences().edit();
    editor.putBoolean(key, value);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
        editor.commit();
    } else {
        editor.apply();
    }
}
 
源代码9 项目: ViewDebugHelper   文件: PreferencesUtil.java
/** 设置Key对应的boolean值 */
public static boolean setBoolValue(Context context,String key, boolean value) {
	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
	Editor editor = prefs.edit();
	editor.putBoolean(key, value);
	return editor.commit();
}
 
源代码10 项目: JianDan_OkHttpWithVolley   文件: SharedPreUtils.java
public static void setBoolean(Context context, String key, boolean value) {
	SharedPreferences sp = context.getSharedPreferences(
			SHARED_PREFERANCE_NAME, Context.MODE_PRIVATE);
	Editor editor = sp.edit();
	editor.putBoolean(key, value);
	editor.commit();
}
 
源代码11 项目: AlarmOn   文件: AlarmClockService.java
public void fixPersistentSettings() {
  final String badDebugName = "DEBUG_MODE\"";
  final String badNotificationName = "NOTFICATION_ICON";
  final String badLockScreenName = "LOCK_SCREEN\"";
  final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  Map<String, ?> prefNames = prefs.getAll();
  // Don't do anything if the bad preferences have already been fixed.
  if (!prefNames.containsKey(badDebugName) &&
      !prefNames.containsKey(badNotificationName) &&
      !prefNames.containsKey(badLockScreenName)) {
    return;
  }
  Editor editor = prefs.edit();
  if (prefNames.containsKey(badDebugName)) {
    editor.putString(AppSettings.DEBUG_MODE, prefs.getString(badDebugName, null));
    editor.remove(badDebugName);
  }
  if (prefNames.containsKey(badNotificationName)){
    editor.putBoolean(AppSettings.NOTIFICATION_ICON, prefs.getBoolean(badNotificationName, true));
    editor.remove(badNotificationName);
  }
  if (prefNames.containsKey(badLockScreenName)) {
    editor.putString(AppSettings.LOCK_SCREEN, prefs.getString(badLockScreenName, null));
    editor.remove(badLockScreenName);
  }
  editor.apply();
}
 
源代码12 项目: RetroMusicPlayer   文件: PreferenceUtil.java
public void setColoredAppShortcuts(final boolean value) {
    final Editor editor = mPreferences.edit();
    editor.putBoolean(COLORED_APP_SHORTCUTS, value);
    editor.apply();
}
 
源代码13 项目: TowerCollector   文件: BooleanPreferenceProvider.java
@Override
void setPreferenceValue(Editor editor, @StringRes int valueKey, Boolean value) {
    String key = context.getString(valueKey);
    editor.putBoolean(key, value);
}
 
源代码14 项目: letv   文件: PreferencesManager.java
public void setChannelShow(boolean isShow) {
    Editor editor = context.getSharedPreferences(SETTINGS, 4).edit();
    editor.putBoolean("isChannelShow", isShow);
    editor.commit();
}
 
源代码15 项目: styT   文件: kbili.java
public static void a(Context context, String str, boolean z) {
    Editor edit = a(context).edit();
    edit.putBoolean(str, z);
    edit.apply();
}
 
源代码16 项目: letv   文件: AlbumVideoController.java
private void setPreferenceValue(Context context, int type, boolean value) {
    Editor editor = context.getSharedPreferences("gesture", 0).edit();
    editor.putBoolean(type == 0 ? "isFirstPush" : "isFirstDownload", false);
    editor.commit();
}
 
源代码17 项目: javaide   文件: PreferenceHelper.java
public static void setWidgetExistsPreference(Context context, int[] appWidgetIds) {

        SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);

        Editor editor = sharedPrefs.edit();

        for (int appWidgetId : appWidgetIds) {
            String widgetExists = WIDGET_EXISTS_PREFIX.concat(Integer.toString(appWidgetId));
            editor.putBoolean(widgetExists, true);
        }

        editor.commit();


    }
 
源代码18 项目: matlog   文件: PreferenceHelper.java
public static void setWidgetExistsPreference(Context context, int[] appWidgetIds) {

        SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);

        Editor editor = sharedPrefs.edit();

        for (int appWidgetId : appWidgetIds) {
            String widgetExists = WIDGET_EXISTS_PREFIX.concat(Integer.toString(appWidgetId));
            editor.putBoolean(widgetExists, true);
        }

        editor.apply();

    }
 
源代码19 项目: java-n-IDE-for-Android   文件: PreferenceHelper.java
public static void setWidgetExistsPreference(Context context, int[] appWidgetIds) {

        SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);

        Editor editor = sharedPrefs.edit();

        for (int appWidgetId : appWidgetIds) {
            String widgetExists = WIDGET_EXISTS_PREFIX.concat(Integer.toString(appWidgetId));
            editor.putBoolean(widgetExists, true);
        }

        editor.commit();


    }
 
源代码20 项目: Aria   文件: SharePreUtil.java
/**
 * 存储Boolean值到配置文件
 *
 * @param preName 配置文件名
 * @param key 键值
 * @param value 需要存储的boolean值
 */
public static Boolean putBoolean(String preName, Context context, String key, Boolean value) {
  SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE);
  Editor editor = pre.edit();
  editor.putBoolean(key, value);
  return editor.commit();
}