0Pricing
Android Academy · Lesson

rememberSaveable

Keep state across configuration changes.

The Problem with remember

remember survives recomposition, but not configuration changes like screen rotation. When the activity is recreated, remembered state is lost and resets to its initial value.

Enter rememberSaveable

rememberSaveable works like remember but also saves the value across configuration changes and process death, then restores it.

var count by rememberSaveable { mutableStateOf(0) }

All lessons in this course

  1. State with remember and mutableStateOf
  2. Recomposition Explained
  3. State Hoisting
  4. rememberSaveable
← Back to Android Academy