Java Utililty Methods Preference Get

List of utility methods to do Preference Get

Description

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

Method

booleangetPreference(String key, Boolean defaultValue)
get Preference
return prefs.getBoolean(key, defaultValue);
PreferencesgetPreferences()
Provides direct access to the preferences node where VCHILL configuration information is stored.
return prefs;
PreferencesgetPreferences(final Class preferencesClass)
get Preferences
final String preferenceGroup = preferencesClass.getName();
return getUserPreferences(preferenceGroup);
PreferencesgetPrefs(Class cls)
get Prefs
return Preferences.userNodeForPackage(cls);
String[]getPrefsStrings(Preferences prefs, String key)
get Prefs Strings
ArrayList<String> arr = new ArrayList<String>();
for (int i = 0; i < 10000; i++) {
    String s = prefs.get(key + (i + 1), null);
    if (s == null)
        break;
    arr.add(s);
return arr.toArray(new String[arr.size()]);
...
String[]getStringArray(final String key, final String[] defaultValue)
Gets an array of string values from the preferences object
try {
    String val = prefs.get(key, arrayToString(defaultValue));
    if (val.equals(""))
        return new String[0];
    return val.split("\\*");
} catch (Exception e) {
    return defaultValue;
PreferencesgetUserPreferences()
Returns the root user preferences node.
Preferences retVal = Preferences.userRoot().node(PREF_ROOT);
return retVal;
PreferencesgetUserPreferences()
Retrieves the preference package based on the specified preferenceClass
return Preferences.userNodeForPackage(mainAppClass);
PreferencesgetUserPreferences(final String preferenceGroup)
get User Preferences
final Preferences userRoot = Preferences.userRoot();
final Preferences preferences = userRoot.node(preferenceGroup);
return preferences;
PreferencesgetUserPrefsNode(Object mainClassInstance)
Gets the Preferences node for a package, given one class in the package (either by reference or by reference to its Class object).
Class clazz;
if (mainClassInstance instanceof Class)
    clazz = (Class) mainClassInstance;
else
    clazz = mainClassInstance.getClass();
return Preferences.userNodeForPackage(clazz);