The HostPreferences class allows programs to store their own user preferences (for example, saved form information) in the application's preference database. Preference key names normally have a dotted namespace format such as 'program_name.component.preference_name', and programs which use this class should follow this convention.
// instantiate a preferences object
var prefs = new HostPreferences;
// set an preference value
prefs.setValue("myextension.mysection.mypref", "This is a test");
// get a preference value
var value = prefs.getValue("myextension.mysection.mypref");
// display it
alert(value);
// get all preferences
var preferences;
var all_prefs = prefs.getAll();
for (var pref_name in all_prefs)
{
preferences += pref_name;
preferences += " equals ";
preferences += all_prefs[pref_name];
preferences += "
";
}
alert(preferences);
True if the preference was successfully deleted from the preference database, false otherwise.
Deletes the preference entry specified in the pref_name parameter. If the value doesn't exist in the application's preference database, or the value could not be deleted, false is returned.
True if the preference exists, false otherwise.
Checks if the preference specified in the pref_name parameter exists in the application database.
An array containing all preferences, or null if the call failed
This method returns all preferences in the application preference database. The object returned is a |dictionary array| indexed by preference name and containing the preference values. See the example for more information on using this method.
The value of the preference, or null if the preference was not found or could not be retrieved.
Retrieves the value of the preference specified in the pref_name parameter. If the value doesn't exist in the application's preference database, or the value could not be retrieved, null is returned. Otherwise either a string or numeric value is returned containing the preference value.
True if the preference was properly set, false otherwise
Sets the value of a preference in the application preference database. If the preference entry does not already exist, a new entry is created. If the preference entry does already exist, the old value is replaced with the value passed to this method. A string, number, or boolean value may be passed in the value parameter.