Skip to main content

DevicePreferences

Namespace: Wisej.Hybrid

Assembly: Wisej.Hybrid (4.1.0.0)

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

public class DevicePreferences

Access this class through the Device singleton.

Methods​

Instance member Clear(sharedName)​

Clears all preferences.

ParameterTypeDescription
sharedName optionalStringAn optional name for a shared preferences space.

Instance member ContainsKey(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 member ContainsKeyAsync(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: Task<Boolean>. true if the preference contains the key; otherwise, false.

Instance member Get(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 member GetAsync(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: Task<Object>. The value of the preference if it exists; otherwise, the default value.

Instance member Remove(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 member Set(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 member Set(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.