# PreferencesGlanceStateDefinition

Artifact: [androidx.glance:glance](https://developer.android.com/jetpack/androidx/releases/glance) [View Source](https://cs.android.com/search?q=file:androidx/glance/state/GlanceStateDefinition.kt+class:androidx.glance.state.PreferencesGlanceStateDefinition) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/glance#1.0.0)


```
object PreferencesGlanceStateDefinition : GlanceStateDefinition<Preferences>
```

<br />

*** ** * ** ***

Base class helping the creation of a state using DataStore's `https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences`.

## Summary

| ### Public functions |
|---|---|
| `open suspend https://developer.android.com/reference/kotlin/androidx/datastore/core/DataStore<https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences>` | `https://developer.android.com/reference/kotlin/androidx/glance/state/PreferencesGlanceStateDefinition#getDataStore(android.content.Context,kotlin.String)(context: https://developer.android.com/reference/android/content/Context.html, fileKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Creates the underlying data store. |
| `open https://developer.android.com/reference/java/io/File.html` | `https://developer.android.com/reference/kotlin/androidx/glance/state/PreferencesGlanceStateDefinition#getLocation(android.content.Context,kotlin.String)(context: https://developer.android.com/reference/android/content/Context.html, fileKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` This file indicates the location of the persisted data. |

## Public functions

### getDataStore

```
open suspend fun getDataStore(context: Context, fileKey: String): DataStore<Preferences>
```

Creates the underlying data store.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | The context used to create locate the file directory |
| `fileKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The unique string key used to name and identify the data file corresponding to a remote UI. Each remote UI has a unique UI key, used to key the data for that UI. |

### getLocation

```
open fun getLocation(context: Context, fileKey: String): File
```

This file indicates the location of the persisted data.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | The context used to create the file directory |
| `fileKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The unique string key used to name and identify the data file corresponding to a remote UI. Each remote UI has a unique UI key, used to key the data for that UI. |