# androidx.glance.appwidget.state

## Top-level functions summary

|---|---|
| `suspend T` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/glance/appwidget/state/package-summary#getAppWidgetState(android.content.Context,androidx.glance.state.GlanceStateDefinition,androidx.glance.GlanceId)( context: https://developer.android.com/reference/android/content/Context.html, definition: https://developer.android.com/reference/kotlin/androidx/glance/state/GlanceStateDefinition<T>, glanceId: https://developer.android.com/reference/kotlin/androidx/glance/GlanceId )` Retrieve the state of an app widget. |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/glance/appwidget/state/package-summary#updateAppWidgetState(android.content.Context,androidx.glance.GlanceId,kotlin.coroutines.SuspendFunction1)( context: https://developer.android.com/reference/android/content/Context.html, glanceId: https://developer.android.com/reference/kotlin/androidx/glance/GlanceId, updateState: suspend (https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/MutablePreferences) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Update the state of an app widget using the global PreferencesGlanceStateDefinition. |
| `suspend T` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/glance/appwidget/state/package-summary#updateAppWidgetState(android.content.Context,androidx.glance.state.GlanceStateDefinition,androidx.glance.GlanceId,kotlin.coroutines.SuspendFunction1)( context: https://developer.android.com/reference/android/content/Context.html, definition: https://developer.android.com/reference/kotlin/androidx/glance/state/GlanceStateDefinition<T>, glanceId: https://developer.android.com/reference/kotlin/androidx/glance/GlanceId, updateState: suspend (T) -> T )` Update the state of an app widget. |

## Extension functions summary

|---|---|
| `suspend T` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidget.https://developer.android.com/reference/kotlin/androidx/glance/appwidget/state/package-summary#(androidx.glance.appwidget.GlanceAppWidget).getAppWidgetState(android.content.Context,androidx.glance.GlanceId)( context: https://developer.android.com/reference/android/content/Context.html, glanceId: https://developer.android.com/reference/kotlin/androidx/glance/GlanceId )` Get the state of an App Widget. |

## Top-level functions

### getAppWidgetState

Artifact: [androidx.glance:glance-appwidget](https://developer.android.com/jetpack/androidx/releases/glance) [View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/state/GlanceAppWidgetState.kt+function:getAppWidgetState)

```
suspend fun <T : Any?> getAppWidgetState(
    context: Context,
    definition: GlanceStateDefinition<T>,
    glanceId: GlanceId
): T
```

Retrieve the state of an app widget.

The state definition must be the one used for that particular app widget.

### updateAppWidgetState

Artifact: [androidx.glance:glance-appwidget](https://developer.android.com/jetpack/androidx/releases/glance) [View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/state/GlanceAppWidgetState.kt+function:updateAppWidgetState) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/glance#1.0.0)

```
suspend fun updateAppWidgetState(
    context: Context,
    glanceId: GlanceId,
    updateState: suspend (MutablePreferences) -> Unit
): Unit
```

Update the state of an app widget using the global PreferencesGlanceStateDefinition.

The state definition must be the one used for that particular app widget.

### updateAppWidgetState

Artifact: [androidx.glance:glance-appwidget](https://developer.android.com/jetpack/androidx/releases/glance) [View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/state/GlanceAppWidgetState.kt+function:updateAppWidgetState)

```
suspend fun <T : Any?> updateAppWidgetState(
    context: Context,
    definition: GlanceStateDefinition<T>,
    glanceId: GlanceId,
    updateState: suspend (T) -> T
): T
```

Update the state of an app widget.

The state definition must be the one used for that particular app widget.

## Extension functions

### GlanceAppWidget.getAppWidgetState

Artifact: [androidx.glance:glance-appwidget](https://developer.android.com/jetpack/androidx/releases/glance) [View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/state/GlanceAppWidgetState.kt+function:getAppWidgetState)

```
suspend fun <T : Any?> GlanceAppWidget.getAppWidgetState(
    context: Context,
    glanceId: GlanceId
): T
```

Get the state of an App Widget.