tezvyn:

`remember` vs. `rememberSaveable`: When and why to use each?

Source: developer.android.comadvanced

Tests understanding of state survival in Compose. A good answer contrasts `remember` (for composition) with `rememberSaveable` (for activity recreation/process death), explaining its use of the `Bundle` mechanism. A red flag is confusing the two lifecycles.

This question tests your deep understanding of state lifecycles in Compose, specifically beyond simple recomposition. A strong answer first defines `remember` as retaining state across recompositions, then contrasts it with `rememberSaveable`, which survives activity recreation and process death. You must explain that `rememberSaveable` achieves this by saving state into the `Bundle`, similar to the old `onSaveInstanceState`. The key red flag is failing to distinguish between state lost on config change vs. process death.

Read the original → developer.android.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

`remember` vs. `rememberSaveable`: When and why to use each? · Tezvyn