remember vs. rememberSaveable: When and Why to Use Each

Tests understanding of Compose state survival. `remember` is for recomposition scope. `rememberSaveable` survives activity recreation and process death via a `Bundle`, requiring custom `Saver`s for complex types. Red flag: saying `remember` survives rotation.
This tests your grasp of Compose state lifecycles. A strong answer explains that `remember` only survives recomposition, while `rememberSaveable` survives activity recreation (e.g., rotation) and process death. You should detail its mechanism: saving to a `Bundle` with automatic support for primitives and `Parcelable`, and requiring custom `Saver` objects for complex types. A major red flag is incorrectly stating that `remember` survives configuration changes like screen rotation.
Read the original → developer.android.com
- #android
- #jetpack compose
- #state management
- #architecture
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.