# PreferencesFactory

Added in 1.0.0

*** ** * ** ***


```
public final class PreferencesFactory
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/preferences/core/Preferences` | `https://developer.android.com/reference/androidx/datastore/preferences/core/PreferencesFactory#create(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/preferences/core/Preferences.Pair<@https://developer.android.com/reference/androidx/annotation/NonNull ?>... pairs)` Construct a Preferences object with a list of Preferences.Pair. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/preferences/core/Preferences` | `https://developer.android.com/reference/androidx/datastore/preferences/core/PreferencesFactory#createEmpty()()` Get a new empty Preferences. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/preferences/core/MutablePreferences` | `https://developer.android.com/reference/androidx/datastore/preferences/core/PreferencesFactory#createMutable(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/preferences/core/Preferences.Pair<@https://developer.android.com/reference/androidx/annotation/NonNull ?>... pairs)` Construct a MutablePreferences object with a list of Preferences.Pair. |

## Public methods

### create

Artifact: [androidx.datastore:datastore-preferences-core](https://developer.android.com/jetpack/androidx/releases/datastore) [View Source](https://cs.android.com/search?q=file:androidx/datastore/preferences/core/PreferencesFactory.kt+function:preferencesOf) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)

```
public static final @NonNull Preferences create(@NonNull Preferences.Pair<@NonNull ?>... pairs)
```

Construct a Preferences object with a list of Preferences.Pair. Comparable to mapOf().

Example usage:

```
val counterKey = intPreferencesKey("counter")
val preferences = preferencesOf(counterKey to 100)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/preferences/core/Preferences.Pair<@https://developer.android.com/reference/androidx/annotation/NonNull ?>... pairs` | the key value pairs with which to construct the preferences |

### createEmpty

Artifact: [androidx.datastore:datastore-preferences-core](https://developer.android.com/jetpack/androidx/releases/datastore) [View Source](https://cs.android.com/search?q=file:androidx/datastore/preferences/core/PreferencesFactory.kt+function:emptyPreferences) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)

```
public static final @NonNull Preferences createEmpty()
```

Get a new empty Preferences.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/preferences/core/Preferences` | a new Preferences instance with no preferences set |

### createMutable

Artifact: [androidx.datastore:datastore-preferences-core](https://developer.android.com/jetpack/androidx/releases/datastore) [View Source](https://cs.android.com/search?q=file:androidx/datastore/preferences/core/PreferencesFactory.kt+function:mutablePreferencesOf) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)

```
public static final @NonNull MutablePreferences createMutable(@NonNull Preferences.Pair<@NonNull ?>... pairs)
```

Construct a MutablePreferences object with a list of Preferences.Pair. Comparable to mapOf().

Example usage:

```
val counterKey = intPreferencesKey("counter")
val preferences = mutablePreferencesOf(counterKey to 100)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/preferences/core/Preferences.Pair<@https://developer.android.com/reference/androidx/annotation/NonNull ?>... pairs` | the key value pairs with which to construct the preferences |