> For the complete documentation index, see [llms.txt](https://docs.wisej.com/hybrid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/hybrid/start/api/storage/wisej.hybrid.devicepreferences.md).

# DevicePreferences

Namespace: **Wisej.Hybrid**

Assembly: **Wisej.Hybrid** (3.5.0.0)

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

{% tabs %}
{% tab title="C#" %}

```csharp
public class DevicePreferences
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class DevicePreferences
```

{% endtab %}
{% endtabs %}

Access this class through the [Device](/hybrid/start/api/general/wisej.hybrid.device.md) singleton.

## Constructors

### ![](/files/CCV9PPenlC1YZvNh1I6R)DevicePreferences()

Initializes a new instance of [DevicePreferences](/hybrid/start/api/storage/wisej.hybrid.devicepreferences.md).

## Methods

### ![](/files/CCV9PPenlC1YZvNh1I6R)Clear(sharedName)

Clears all preferences.

| Parameter                                       | Type                                                          | Description                                      |
| ----------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------ |
| **sharedName** ![](/files/hKoZkt511VItWvI9RDIT) | [String](https://docs.microsoft.com/dotnet/api/system.string) | An optional name for a shared preferences space. |

### ![](/files/CCV9PPenlC1YZvNh1I6R)ContainsKey(key, sharedName)

Checks if the preferences contain a given key.

| Parameter                                       | Type                                                          | Description                                      |
| ----------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------ |
| **key**                                         | [String](https://docs.microsoft.com/dotnet/api/system.string) | The key to check within the preferences.         |
| **sharedName** ![](/files/hKoZkt511VItWvI9RDIT) | [String](https://docs.microsoft.com/dotnet/api/system.string) | An optional name for a shared preferences space. |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if the preference contains the key; otherwise, false.

### ![](/files/CCV9PPenlC1YZvNh1I6R)Get(key, defaultValue, sharedName)

Retrieves the value of a preference specified by the key.

| Parameter                                       | Type                                                          | Description                                                   |
| ----------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------- |
| **key**                                         | [String](https://docs.microsoft.com/dotnet/api/system.string) | The key for the desired preference.                           |
| **defaultValue**                                | [Object](https://docs.microsoft.com/dotnet/api/system.object) | The default value to return if the preference does not exist. |
| **sharedName** ![](/files/hKoZkt511VItWvI9RDIT) | [String](https://docs.microsoft.com/dotnet/api/system.string) | An optional name for a shared preferences space.              |

**Returns:** [Object](https://docs.microsoft.com/dotnet/api/system.object). The value of the preference if it exists; otherwise, the default value.

### ![](/files/CCV9PPenlC1YZvNh1I6R)Remove(key, sharedName)

Removes a preference specified by the key.

| Parameter                                       | Type                                                          | Description                                      |
| ----------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------ |
| **key**                                         | [String](https://docs.microsoft.com/dotnet/api/system.string) | The key for the preference to remove.            |
| **sharedName** ![](/files/hKoZkt511VItWvI9RDIT) | [String](https://docs.microsoft.com/dotnet/api/system.string) | An optional name for a shared preferences space. |

### ![](/files/CCV9PPenlC1YZvNh1I6R)Set(key, value, sharedName)

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

| Parameter                                       | Type                                                            | Description                                      |
| ----------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------ |
| **key**                                         | [String](https://docs.microsoft.com/dotnet/api/system.string)   | The key for the desired preference.              |
| **value**                                       | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | The value to set for the preference.             |
| **sharedName** ![](/files/hKoZkt511VItWvI9RDIT) | [String](https://docs.microsoft.com/dotnet/api/system.string)   | An optional name for a shared preferences space. |

### ![](/files/CCV9PPenlC1YZvNh1I6R)Set(key, value, sharedName)

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

| Parameter                                       | Type                                                          | Description                                      |
| ----------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------ |
| **key**                                         | [String](https://docs.microsoft.com/dotnet/api/system.string) | The key for the desired preference.              |
| **value**                                       | [String](https://docs.microsoft.com/dotnet/api/system.string) | The value to set for the preference.             |
| **sharedName** ![](/files/hKoZkt511VItWvI9RDIT) | [String](https://docs.microsoft.com/dotnet/api/system.string) | An optional name for a shared preferences space. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/hybrid/start/api/storage/wisej.hybrid.devicepreferences.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
