Learn how to establish and manage state in your Compose-based app and how
to configure the UI to react to changes in state. See how to create observable
states, how to retain state across recompositions or configuration changes, and
how to structure your composables for optimal data flow.
Key points
If your app's state is internal to a composable, use remember to persist
the state across re-composition.
Use rememberSaveable to persist the state across configuration
changes.
State hoisting is a programming pattern where you move the state to the
caller of a composable. Where possible, use state hoisting to make the
composable more reusable and testable.
Use the ViewModel class to hold an exposed state in an observable
state holder, better encapsulating the state and creating a single source of
truth for the UI.
With the ability to publish rapidly to over 2 billion active Android devices, Google Play helps you grow a global audience for your apps and games and earn revenue.
With the ability to publish rapidly to over 2 billion active Android devices, Google Play helps you grow a global audience for your apps and games and earn revenue.
Updated Mar 4, 2025
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-06 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-06 UTC."],[],[]]