0Pricing
Jetpack Compose Academy · Lesson

rememberSaveable Across Rotation

Keep state through configuration changes.

rememberSaveable Across Rotation is a free Jetpack Compose Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Jetpack Compose Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The Rotation Problem

Rotate the screen and your tap counter snaps back to zero. That is because a configuration change recreates the whole Activity.

remember Isn't Enough

remember survives recomposition, but not Activity recreation. When the Activity restarts, remembered state is gone for good.

What Triggers Recreation

Rotation, language switches, and dark-mode toggles are configuration changes. Each one tears down and rebuilds your UI from scratch.

Meet rememberSaveable

rememberSaveable works like remember but also saves the value into the saved instance state, so it survives recreation.

var count by rememberSaveable { mutableStateOf(0) }

Just Swap the Call

Often the fix is a one-word change: replace remember with rememberSaveable and your counter now keeps its value after rotation.

What Can Be Saved

It saves types that fit in a Bundle out of the box: Int, String, Boolean, and other primitives. Most simple state just works.

var name by rememberSaveable { mutableStateOf("") }

Custom Types Need a Saver

For your own classes, give rememberSaveable a Saver that tells it how to store and restore the object as bundle-safe data.

Data Classes Made Easy

For Kotlin data classes you can use the mapSaver or listSaver helpers, or annotate with Parcelize, to make saving simple.

@Parcelize
data class User(val name: String) : Parcelable

It Is Not Forever

rememberSaveable survives rotation and brief backgrounding, but not a full app kill. For permanent data you still need storage.

When to Reach for It

Use rememberSaveable for transient UI state you want to keep through rotation, like a counter, a typed query, or a tab index.

remember vs Saveable

Rule of thumb: use remember for cheap or recomputable values, and rememberSaveable when losing the value on rotation would annoy the user.

Quick Check

Which API keeps state through a screen rotation?

Recap

You learned that rememberSaveable keeps transient UI state alive through rotation and config changes, while remember does not. Nicely done! 🎉

Frequently asked questions

Is the “rememberSaveable Across Rotation” lesson free?

Yes — the full text of “rememberSaveable Across Rotation” is free to read here on the web, and the Jetpack Compose Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Jetpack Compose Academy course, upgrade to CoddyKit PRO.

What will I learn in “rememberSaveable Across Rotation”?

Keep state through configuration changes. You practise Jetpack Compose Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Jetpack Compose Academy?

No prior experience is required. Jetpack Compose Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “rememberSaveable Across Rotation” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Jetpack Compose Academy lesson?

Yes. Every Jetpack Compose Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. remember & mutableStateOf
  2. Recomposition: What Triggers a Redraw
  3. Build a Tap Counter
  4. rememberSaveable Across Rotation
← Back to Jetpack Compose Academy