private void savePositionAndSize() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(PopupVideoPlayer.this); sharedPreferences.edit().putInt(POPUP_SAVED_X, popupLayoutParams.x).apply(); sharedPreferences.edit().putInt(POPUP_SAVED_Y, popupLayoutParams.y).apply(); sharedPreferences.edit().putFloat(POPUP_SAVED_WIDTH, popupLayoutParams.width).apply(); }
public SharedPreferencesUtil putFloat(String key, float value) { editor.putFloat(key, value); editor.commit(); return this; }
public void putFloatValue(String key, Float value) { if (key != null && !key.equals("")) { editor = sp.edit(); editor.putFloat(key, value); editor.commit(); } } }
break; case FLOAT: editor.putFloat(key, Float.valueOf(nextArgValue(argsIter))); break; case STRING:
/** * Put float to preferences with custom preference * * @param context * @param preferenceName The custom preference name * @param key The name of the preference to modify * @param value The new value for the preference * @return Returns true if the new values were successfully written to persistent storage. */ public static boolean putFloat(Context context, String preferenceName, String key, float value) { SharedPreferences sharedPreferences = context.getSharedPreferences(preferenceName, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putFloat(key, value); return editor.commit(); }
/** * put float preferences * * @param context * @param key The name of the preference to modify * @param value The new value for the preference * @return True if the new values were successfully written to persistent storage. */ public static boolean putFloat(Context context, String key, float value) { SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putFloat(key, value); return editor.commit(); }
/** * put float preferences * * @param context * @param key The name of the preference to modify * @param value The new value for the preference * @return True if the new values were successfully written to persistent storage. */ public static boolean putFloat(Context context, String key, float value) { SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putFloat(key, value); return editor.commit(); }
public static void putFloat(String key, float value) { sSettingsPre.edit().putFloat(key, value).apply(); }
public boolean setFloatCommit(String key, float value) { return mPreferences.edit().putFloat(key, value).commit(); }
public void setFloatApply(String key, float value) { mPreferences.edit().putFloat(key, value).apply(); }
private static void assignByType( SharedPreferences.Editor editor, String key, Object value) throws IllegalArgumentException { if (value instanceof Integer) { editor.putInt(key, (Integer)value); } else if (value instanceof Long) { editor.putLong(key, (Long)value); } else if (value instanceof Float) { editor.putFloat(key, (Float)value); } else if (value instanceof Boolean) { editor.putBoolean(key, (Boolean)value); } else if (value instanceof String) { editor.putString(key, (String)value); } else if (value instanceof Set) { putStringSet(editor, key, (Set<String>)value); } else { throw new IllegalArgumentException("Unsupported type=" + value.getClass().getName()); } }
public static void setSharedFloatData(Context context, String key, float value) { if (sp == null) { init(context); } sp.edit().putFloat(key, value).commit(); }
@Before public void setUp() { context = ApplicationProvider.getApplicationContext(); sharedPreferences = context.getSharedPreferences(FILENAME, Context.MODE_PRIVATE); // Ensure no shared preferences have leaked from previous tests. assertThat(sharedPreferences.getAll()).hasSize(0); editor = sharedPreferences.edit(); editor.putBoolean("boolean", true); editor.putFloat("float", 1.1f); editor.putInt("int", 2); editor.putLong("long", 3L); editor.putString("string", "foobar"); stringSet.add( "string1" ); stringSet.add( "string2" ); stringSet.add( "string3" ); editor.putStringSet("stringSet", stringSet); }
private static void putFloat(String key, float value) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(BilibiliApp.getInstance()); Editor editor = sharedPreferences.edit(); editor.putFloat(key, value); editor.apply(); }
private static void setScreenBrightness(@NonNull final Context context, final float screenBrightness, final long timestamp) { SharedPreferences.Editor editor = getPreferences(context).edit(); editor.putFloat(context.getString(R.string.screen_brightness_key), screenBrightness); editor.putLong(context.getString(R.string.screen_brightness_timestamp_key), timestamp); editor.apply(); }
@Override protected void putInternal(Float value) { apply(edit().putFloat(key, value)); }
public T put(float value) { editorHelper.getEditor().putFloat(key, value); return editorHelper; } }
@Override public Preferences putFloat (String key, float val) { edit(); editor.putFloat(key, val); return this; }
@Override public Preferences putFloat (String key, float val) { edit(); editor.putFloat(key, val); return this; }