Difference between remember and rememberSaveable

WHAT IT TESTS: Compose state vs saved state. ANSWER OUTLINE: remember survives recompositions only; rememberSaveable uses Bundle state for config changes and process death; use for UI state after recreation. RED FLAG: Claiming it uses ViewModel or disk.
WHAT IT TESTS: Distinguishing ephemeral recompositions from config changes and process death in Compose, plus the Bundle-based Saved State mechanism. ANSWER OUTLINE: First, remember holds state across recompositions but dies on config changes and process death. Second, rememberSaveable persists via SavedStateRegistry into a Bundle, surviving both. Third, use it for small UI state that is Parcelable, primitive, or uses a custom Saver. RED FLAG: Saying it relies on ViewModel, persists to disk, or is suitable for large objects.
Read the original → developer.android.com
- #android
- #jetpack-compose
- #state-management
- #kotlin
- #saved-state
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.