---
title: "updateAppWidgetState"
description: "Update the state of an app widget.

The state definition must be the one used for that particular app widget."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-android'>Android</div>


```kotlin
public suspend fun <T> 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.



<div class='sourceset sourceset-android'>Android</div>


```kotlin
public suspend fun updateAppWidgetState(
    context: Context,
    glanceId: GlanceId,
    updateState: suspend (MutablePreferences) -> 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.



