I have an Android application that stores about 25-40K of private app data in few files. By default system stores these files in the directory /data/data/'my app package'/files. When the user goes to "Setting->Applications->Manage Applications->'My app package'" and chooses the "Clear data" option, all the files, databases folders for this app is being deleted. I need to keep my data on the device until the app is "uninstalled".
Is there a way to keep my application data "on the device" somewhere without being deleted? My device is not rooted. My app is not meant to be on rooted dev开发者_StackOverflow社区ices.
Note: I saw the /data/data/'my app package'/lib directory is not being deleted using the "clear data" option. But I couldn't programmatically write to this direcroty. I get permission denied. Is there a way to use this directory to store my data? Is there a way to use NDK (not worked on it yet) to keep the data safe? Is there a way to keep the data in application resource or something like a DLL resource in Windows programing.
Any help please to get me out of this jam?
The following works for me: android:manageSpaceActivity=".ActivityOfMyChoice"
Then instead of "Clear Data"
, there is a button for "Manage Space"
which launches ActivityOfMyChoice
It's working for my app, and I see it working on Dolphin Browser (which is what prompted me to find this info).
I'm using a Samsung Captivate (AT&T Galaxy S) with stock 2.2 (Froyo). I don't know if some devices might display both, or not.
Some devices may still display both, or may just not show Manage Space at all
When the user goes to "Setting->Applications->Manage Applications->'My app package'" and chooses the "Clear data" option, all the files, databases folders for this app is being deleted. I need to keep my data on the device until the app is "uninstalled".
This isn't possible for security reasons, see this question.
Add
android:allowClearUserData="false"
to Application tag of the manifiest it will change the button Clear Data to Manage Space
精彩评论