Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Preventing Application data or files being deleted thru "Clear Data" settings option

Tags:

android

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 devices.

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?

like image 331
user702426 Avatar asked Apr 11 '11 15:04

user702426


1 Answers

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

like image 142
Reed Avatar answered Nov 15 '22 20:11

Reed