简体   繁体   中英

android: onRetainNonConfigurationInstance and how to make changes to what’s saved between apk updates?

I currently have a app on the market it saves some data with “onRetainNonConfigurationInstance” now I want to add some more variables to the saved data and update the already published app.

It seems to me that the when the new apk runs for the first time and does a “getLastNonConfigurationInstance()” the new variables I added will not be present. Is there a way to handle this? Will this cause a problem if I dont handle it (to me it seems like it would)?

No, any data that could have been "stored" from the last onRetainNonConfigurationInstance will be gone when you update the app, since your program will be killed when doing the upgrade. In short, you don't need to worry about that.

You can reproduce the behavior by force quitting your app. You'll see that getLastNonConfigurationInstance() will be null the first time you start your application from a fully closed state.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM