Skip to content
Preptima
mediumConceptScenarioMidSenior

How does a ViewModel survive a configuration change, and what does it not survive that SavedStateHandle is for?

4 min readUpdated 2026-08-15

Answer

Short answer

A ViewModel outlives a configuration change like rotation because the Activity is recreated while the ViewModelStore is retained, but it does not survive process death from memory pressure, which is what SavedStateHandle exists to restore state across.

Keep android explicit in the answer because that is the concept the interviewer is actually trying to test. A good android explanation names the trade-off, the failure mode, and the evidence you would use before choosing.

Was this answer helpful?

Likely follow-ups

  • How would you test that your screen restores correctly after system-initiated process death, given that a debugger attached usually prevents it?
  • What kind of data belongs in SavedStateHandle versus what belongs in a database or a repository cache?
  • Why can't you put a large object like a Bitmap directly into SavedStateHandle?
  • What is the practical difference between onCleared() being called and the process being killed without any callback at all?

Related questions

Further reading

Related Topics