防止在清除的应用程序上删除数据库或共享首选项 [英] Prevent deletion of database or shared preference on clear app

查看:70
本文介绍了防止在清除的应用程序上删除数据库或共享首选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想防止清除共享首选项或数据库,以便仅在卸载应用程序时清除。如何在应用程序上确保共享首选项的安全。明确?

I want to prevent the deletion of shared preferences or database on clear such that it will clear only when the app is uninstalled. How can I keep shared preference safe on app. clear?

推荐答案

值得注意的是,Android中存在三种类型的数据清除,您的应用无法控制其中的三种类型:

It is worth noting that there are three types of data clearing in Android, of which your application has no control over:


  • 清除数据

  • 清除缓存

  • 清除默认值

清除数据
清除数据将清除应用程序工作目录下的所有内容。这包括驻留在应用程序目录中的应用程序保存的所有共享首选项,数据库和文件。这还将清除应用程序的缓存,因为它也是应用程序工作目录的一部分。

Clear Data Clear data will clear everything under the application's working directory. This includes any shared preferences, databases and files saved by the application which reside in the application directory. This will also clear the application's cache, as it is also part of the application's working directory.

清除缓存
访问缓存目录以将文件保存到其中,主要用于缓存目的,例如生成的图像或临时文件。

Clear Cache The application has access to a cache directory to save files to, mainly for the purpose of caching such as generated images or temporary files.

清除默认值
此选项将清除向该应用程序注册的所有意图。

Clear Defaults This options will clear any intents registered to this application.

卸载应用程序将清除所有三组数据。因此,在两次安装之间维护数据的唯一方法是将其保存到外部存储中,但是请注意,用户和每个应用程序都可以访问外部存储,因此可以随时对其进行修改或删除。

Uninstalling an application will clear all three sets of data. Therefore the only way to maintain data between installs is to save it to external storage, but note that both the user and every application has access to the external storage and therefore may be modified or deleted at any point.

值得阅读的链接:

http://developer.android.com/guide/topics/data/data-storage.html#

Android:Android:永久保存文件(即使清除数据后,卸载)

清除缓存&清除Android设置中的数据

这篇关于防止在清除的应用程序上删除数据库或共享首选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆