Can I save data to internal storage on Android so that the user cannot delete it?

I understand that if I save the data to the internal storage of the Android platform, it can be easily deleted by the user by following the link: Settings -> Apps -> Manage apps -> (select your app) -> Clear data

Is there a way to keep the data (or SharedPreferences) in such a way that the user doesn't delete it?

+3


source to share


2 answers


There are two sides you are asking about.

First, there is a way to store data that the user cannot delete.

NO, this is impossible and it shouldn't be.

Secondly, there is a way to store data outside of the area, which is removed when "clear data" is called during application control.

Yes it is possible. You need to add permission to access the SD card, see here and here . Find

WRITE_EXTERNAL_STORAGE

      



For more details on accessing external storage see here

EDIT:

There is no way to store the data (SharedPreferences) in a way that will not be deleted by the user, and MUST NOT be. This would be a great way for a malicious app to do malicious things on the phone (to, if nothing else, fill up the internal storage on the phone and make it fail, with no way to "wipe data" to fix it).

To keep data that is not deleted, use the "Clear data" option in the settings. Your options are to save to "external storage", which counts as both an "internal SD card" and an "external SD card". Basically, anywhere that is NOT deleted with Clear Data.

I believe this answers your question. If not, then clarify what you want to know instead of saying "he doesn't answer my question" in the comment. Tell me that I am not answering and PLEASE choose the most correct answer, if any.

+6


source


If the data is small, write it to an xml file in your project. There is no way to uninstall it without uninstalling the app.



0


source







All Articles