Skip to main content

DevicePreferences

Namespace: Wisej.Hybrid

Assembly: Wisej.Hybrid

Manages device preferences, allowing retrieval and storage of user preferences.

public class DevicePreferences

Access this class through the Device singleton.

Constructors

Instance memberDevicePreferences()

Initializes a new instance of DevicePreferences.

Methods

Instance memberClear(sharedName)

Clears all preferences.

ParameterTypeDescription
sharedName optionalStringAn optional name for a shared preferences space.

Instance memberContainsKey(key, sharedName)

Checks if the preferences contain a given key.

ParameterTypeDescription
keyStringThe key to check within the preferences.
sharedName optionalStringAn optional name for a shared preferences space.

Returns: Boolean. true if the preference contains the key; otherwise, false.

Instance memberGet(key, defaultValue, sharedName)

Retrieves the value of a preference specified by the key.

ParameterTypeDescription
keyStringThe key for the desired preference.
defaultValueObjectThe default value to return if the preference does not exist.
sharedName optionalStringAn optional name for a shared preferences space.

Returns: Object. The value of the preference if it exists; otherwise, the default value.

Instance memberRemove(key, sharedName)

Removes a preference specified by the key.

ParameterTypeDescription
keyStringThe key for the preference to remove.
sharedName optionalStringAn optional name for a shared preferences space.

Instance memberSet(key, value, sharedName)

Sets the value of a boolean preference specified by the key.

ParameterTypeDescription
keyStringThe key for the desired preference.
valueBooleanThe value to set for the preference.
sharedName optionalStringAn optional name for a shared preferences space.

Instance memberSet(key, value, sharedName)

Sets the value of a string preference specified by the key.

ParameterTypeDescription
keyStringThe key for the desired preference.
valueStringThe value to set for the preference.
sharedName optionalStringAn optional name for a shared preferences space.