资源在Android应用升级版本时会发生什么变化

huangapple go评论66阅读模式
英文:

What happens to resources when Android upgrade version of an application

问题

我的应用程序带有assets资源(很多),raw资源(很少),以及用户在使用应用程序时创建的其他对象(包括SharedPreferences)。

我无法理解当我安装新版本的应用程序时,所有这些资源会发生什么情况。它们是否被覆盖,还是保留在先前的状态(如果是这样,如何更改它)?

英文:

My application comes with assets resources (a lot), raw resources (a few) and some other objects created by the user when using the app (including SharedPreferences).

I can't manage to understand what happens to all these resources when I install a new version of the app. Are those overridden or do they stay in the previous state (if so how can I change it) ?

答案1

得分: 4

"SharedPreferences" 是 XML 文件,不会捆绑在 APK 内,而是在应用程序安装后使用 SharedPreferences API 时生成的。这些文件创建在您的应用程序数据文件夹中,对应用程序是私有的(除非您另有规定)。它们在应用程序更新期间保持不变。唯一的删除/覆盖方式是:

a) 用户卸载/重新安装应用程序

b) 用户在系统设置中的应用程序设置页面内清除存储(应用程序数据)

c) 您可以通过 SharedPreferences API 或备份/恢复 API 来删除它们

资源随您的 APK(或应用程序包)一起提供。基本上,所有位于 "res/" 文件夹内的样式、字符串、可绘制对象、资源等都会在安装后替换为新 APK 中 "res/" 文件夹的内容。

英文:

The SharedPreferences are xml files that are not bundled within the APK but are generated ones the app is installed and you use the SharedPreferences APIs. These files are created within the data folder of your app and are private to the app (unless you specified otherwise). They remain untouched during updates of the app. The only ways to remove/overwrite them is by one of the following:

a) The user un/reinstalls the app

b) The user clears the Storage (app data) from within the app settings page within the system settings

c) you remove them via the SharedPreferences apis or via the backup/restore APIs

Resources are delivered with your apk (or app bundle). Basically everything within the res/ folder. So all styles, strings, drawables, assets, etc. are replaced with the contents of the res folder of the new APK after the installation.

huangapple
  • 本文由 发表于 2020年8月6日 22:49:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/63286192.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定