Java Utililty Methods Preference Put

List of utility methods to do Preference Put

Description

The list of methods to do Preference Put are organized into topic(s).

Method

voidput(final String key, final boolean value)
Stores a boolean value to the preferences object
prefs.putBoolean(key, value);
booleanputBooleanDontOverwrite(Preferences prefs, String key, boolean value)
put Boolean Dont Overwrite
boolean overwrite = prefs.get(key, null) == null;
if (overwrite) {
    prefs.putBoolean(key, value);
return overwrite;
voidputCLOB(Preferences prefs, String key, String clob)
Store a character large object (CLOB) under the given key in the given preference node.
if (clob == null)
    throw new NullPointerException("CLOB value cannot be null");
if (clob.length() < Preferences.MAX_VALUE_LENGTH && !isCheckVal(clob)) {
    removeCLOB(prefs, key);
    prefs.put(key, clob);
    return;
prefs.put(key, getCheckVal(clob));
...
voidputList(String path, ArrayList list)
Put a list of strings to preferences.
Preferences prefs = createNode(path);
if (prefs == null)
    return;
prefs.putInt("size", list.size());
for (int i = 0; i < list.size(); ++i)
    prefs.put("element_" + i, list.get(i));
voidputPrefsBoolean(Preferences prefs, String key, boolean value, boolean def)
put Prefs Boolean
if (value != def)
    prefs.putBoolean(key, value);
else
    prefs.remove(key);
voidputPrefsStrings(Preferences prefs, String key, String[] strings)
put Prefs Strings
for (int i = 0; i < strings.length; i++)
    prefs.put(key + (i + 1), strings[i]);
for (int i = strings.length; prefs.get(key + (i + 1), null) != null; i++)
    prefs.remove(key + (i + 1));
voidsetLocale(final Locale l)
Sets the new default locale.
Locale.setDefault(l);
final Preferences p = Preferences.userRoot().node(PREFERENCE_NODE);
p.put(LOCALE, encodeLocale(l));
resourceBundle = null; 
voidsetPrefBoolean(Object context, final String key, final boolean value)
set Pref Boolean
prefs = Preferences.userRoot().node(context.getClass().getName());
prefs.putBoolean(key, value);
voidsetUserString(final String preferencesGroup, final String preferenceName, final String value)
set User String
final Preferences preferences = getUserPreferences(preferencesGroup);
preferences.put(preferenceName, value);
voidstoreDiff(Preferences prefs, String key, int prev, int val, int defVal)
store Diff
if (prev != val)
    if (val == defVal)
        prefs.remove(key);
    else
        prefs.putInt(key, val);