简体   繁体   English

android:onRetainNonConfigurationInstance,以及如何更改两次APK更新之间保存的内容?

[英]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.

相关问题 Android:onRetainNonConfigurationInstance()和方向随着不同的布局而改变 - Android: onRetainNonConfigurationInstance() and orientation changes with different layouts 如何在Android的onRetainNonConfigurationInstance()中保存大量对象 - How to save lot of object in onRetainNonConfigurationInstance() in android 维护Android Activity的数据:onPause,onSaveInstanceState,onRetainNonConfigurationInstance - Maintaining Android Activity's data: onPause, onSaveInstanceState, onRetainNonConfigurationInstance OnSaveInstance和OnRetainNonConfigurationInstance之间的区别? - Difference between OnSaveInstance and OnRetainNonConfigurationInstance? Android-将数据库与onRetainNonConfigurationInstance一起使用 - Android - using database with onRetainNonConfigurationInstance Android:onRetainNonConfigurationInstance()已弃用? - Android: onRetainNonConfigurationInstance() deprecated? Android-一种触发onRetainNonConfigurationInstance的方法? - Android - A way to trigger onRetainNonConfigurationInstance? 什么是Android Studio中的APK分析器,以及如何充分利用它? - What is the APK Analyzer in Android Studio and how to make the most of it? 如何使用 buildozer 制作 android APK? - How to make android APK with buildozer? 如何实现onRetainNonConfigurationInstance - how to implement onRetainNonConfigurationInstance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM