Android 提供以下数据存储选项:
Shared Preferences - 将私有(private)原始数据存储在键值对中。
内部存储 - 在设备内存中存储私有(private)数据。
外部存储 - 将公共(public)数据存储在共享的外部存储上。
SQLite 数据库 - 在私有(private)数据库中存储结构化数据。
Cache - 应用程序运行时缓存数据。(空间不足时可以清除)
我想知道的是这些存储的生命周期。
- 哪些存储在应用程序关闭时清除(显然是缓存)
- 哪些存储在应用程序重新安装时清除
- 哪些存储在应用程序更新时清除
- 卸载应用程序时清除哪些存储空间
- 哪些存储会清除应用程序清除数据
- 哪些存储会在移动设备恢复出厂设置时清除
- 哪些存储在 Rom 升级/更改时清除
这个问题的扩展是,在丢失和未授权资源访问方面,使用哪种存储方式我的数据更安全>(用户,如果是 root,则为应用程序)。
最佳答案
Which storage(s) clears on application close (Obviously cache)
缓存
Which storage(s) clears on application re-install
缓存
Which storage(s) clears on application update
缓存
Which storage(s) clears on application un-install
缓存、SQLite、共享首选项
Which storage(s) clears on application clear data
缓存、SQLite、共享首选项
Which storage(s) clears on mobile factory reset
清除所有数据,但不清除外部存储数据
An extension to this question is, using which storage my data is more secure in terms of loss and in terms of access by unauthorized resources (users, applications in case of root).
最好将数据以加密的形式存储在SQLite中。如果您的设备已获得 root 权限,则意味着您甚至可以访问 SQLite。
关于Android - 不同存储选项的生命周期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22149631/