weirdo16 weirdo16 - 5 months ago 7x
Java Question

Is savedInstanceState kept during updates?

So, Activity.onCreate() takes a Bundle as a parameter, by default it's called savedInstanceState. Is the savedInstanceState kept when the app is updated to a newer version? (let's just say through Google Play). Can I put some data in savedInstanceState, update the app to a new version, and still access the data?


Saved instance data is not preserved during application updates. This actually makes sense not only because of the data type potential incompatibility risk among different versions but also because your new binaries could simply be completely new application, sharing just packageId and signing certificate. That's why new version requires restart - after update user will start with fresh state as this is much safer than trying to restore the app to the state it was before update started (which can be simply impossible).

So if you want data to remain unaffected by updates, database or shared preferences is much better choice.