1

My application downloads/creates some files which in turn has link from database, if user deletes file accidentally, but the record in database still exists, which leaves my app with corrupted data.

Is there any way to restrict access to folder only to my app. I created folder in sdcard to store files.

1
  • You can hide the folder, for that check this Nov 25, 2011 at 10:35

3 Answers 3

1

There is currently no way to create undeleteable files on android from a standard app. If your concern is loss of data due to user error, you can:

  1. Store your data server side, and only cache it on the phone. This may be expensive or an invasion of privacy depending on your app, but is the best solution.

  2. Store the files as part of your application's data, and mark in the manifest that it should be stored on the SD card. To do this, add the following line to your manifest: android:installLocation="preferExternal"

More information about external storage here.

0

If the downloaded files are not very big, you can store them in your application folder which only your app can access.

/data/data/your.package.name/
1
  • you can hide files on sdcard by prepending the name with a "." e.g. ".image.jpg". This will hide the file, but only on unix platform. If they mount the sdcard on windows, they'll see these files. There is no other way to restrict access on sdcard. It is supposed to be open for all. See this thread for more details => [link]stackoverflow.com/questions/1129644/… Nov 25, 2011 at 10:45
0

Try to put <.> (<.> = fullstop) at the start of your application's folder name. It'll prevent folder to be shown in standard file manager of android or gallery.

Furthermore there is no way to restrict user from deleting files..:(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.