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


<a id='references'></a>


<h2 id="updateappwidgetstate-context-definition-glanceid-updatestate">updateAppWidgetState</h2>

<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.





<hr class="docs-overload-divider">


<h2 id="updateappwidgetstate-context-glanceid-updatestate">updateAppWidgetState</h2>

<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.