[英]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. 我目前在市场上有一个应用程序,它使用“ onRetainNonConfigurationInstance”保存一些数据,现在我想向已保存的数据添加更多变量,并更新已经发布的应用程序。
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. 在我看来,当新的APK第一次运行并执行“ getLastNonConfigurationInstance()”时,我添加的新变量将不存在。 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. 不,在更新应用程序时,自上一个
onRetainNonConfigurationInstance
以来可能已经“存储”的所有数据都将消失,因为在执行升级时,程序将被杀死。 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. 您将看到,第一次从完全关闭状态启动应用程序时,
getLastNonConfigurationInstance()
将为null。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.