是否有可能阻止共享preferences避免被删除?有可能、preferences

2023-09-07 10:21:35 作者:霸道萝莉

通过在Android默认共享preferences都能够通过电话设置被删除。是否有可能阻止这个?基本上,我想用来存储共享preference在Android文档定义,但不允许以任何理由删除它们。即电话设置,应用程序更新,也不应用卸载。如果这是不可能的,这存储机制将你建议这样做。我需要存储主要是原始数据。

By default Shared Preferences on Android are being able to be deleted by phone setup. Is it possible to block this ?. Basically i would like to store a Shared Preference as defined on Android documentation but not to allow to delete them by any reason. Ie Phone Setup, App update nor App uninstall. If this is not possible, which storage mechanism would you suggest to do this. I need to store is primitive data mostly.

我在做一个应用程序,我需要从用户收集一些数据,并确保他将只有一个机会提供,否则她会被欺骗。我同意,最好的选择是提供存储我的服务器上的数据,但如果用户关闭互联网这种做法是行不通的。我明白了两方面的要求可能很难满足。

I am making an application where I need to collect certain data from user and ensure he will have just one opportunity to provide it, otherwise she would be cheating. I agree, best option is to store the data provided on my server but that approach would not work if user turn off internet. I understand both requirements might be very difficult to meet.

推荐答案

这是可以删除存储在手机上的任何数据。

It is possible to delete any data stored on the phone.

共享preferences,而不是保存到SD卡上的文件时,将应用程序卸载删除。

Shared preferences and files not saved to the SD card will be deleted when the app is uninstalled.

文件保存到SD卡将仍然存在后卸载,但是,用户将有机会获得阅读,过度写,并随意删除这些文件。

Files saved to the SD card will persists after uninstall, however, the user will have access to read, over-write, and delete these files at will.

如果你真正需要永久保存的最好的办法,就是远程存储自己控制的服务器上的数据。

If you need truly permanent storage the best way forward would be to store the data remotely on a server that you control.