DevicePreferences
Namespace: Wisej.Hybrid
Assembly: Wisej.Hybrid
Manages device preferences, allowing retrieval and storage of user preferences.
- C#
- VB.NET
public class DevicePreferences
Public Class DevicePreferences
Access this class through the Device singleton.
Constructors
DevicePreferences()
Initializes a new instance of DevicePreferences.
Methods
Clear(sharedName)
Clears all preferences.
| Parameter | Type | Description |
|---|---|---|
| sharedName | String | An optional name for a shared preferences space. |
ContainsKey(key, sharedName)
Checks if the preferences contain a given key.
| Parameter | Type | Description |
|---|---|---|
| key | String | The key to check within the preferences. |
| sharedName | String | An optional name for a shared preferences space. |
Returns: Boolean. true if the preference contains the key; otherwise, false.
Get(key, defaultValue, sharedName)
Retrieves the value of a preference specified by the key.
| Parameter | Type | Description |
|---|---|---|
| key | String | The key for the desired preference. |
| defaultValue | Object | The default value to return if the preference does not exist. |
| sharedName | String | An optional name for a shared preferences space. |
Returns: Object. The value of the preference if it exists; otherwise, the default value.
Remove(key, sharedName)
Removes a preference specified by the key.
| Parameter | Type | Description |
|---|---|---|
| key | String | The key for the preference to remove. |
| sharedName | String | An optional name for a shared preferences space. |
Set(key, value, sharedName)
Sets the value of a boolean preference specified by the key.
| Parameter | Type | Description |
|---|---|---|
| key | String | The key for the desired preference. |
| value | Boolean | The value to set for the preference. |
| sharedName | String | An optional name for a shared preferences space. |
Set(key, value, sharedName)
Sets the value of a string preference specified by the key.
| Parameter | Type | Description |
|---|---|---|
| key | String | The key for the desired preference. |
| value | String | The value to set for the preference. |
| sharedName | String | An optional name for a shared preferences space. |