Sandeep Manne
Sandeep Manne

Reputation: 6092

Restrict folder access to android apps

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.

Upvotes: 1

Views: 3815

Answers (3)

Awais Tariq
Awais Tariq

Reputation: 7754

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..:(

Upvotes: 0

Charles Munger
Charles Munger

Reputation: 1407

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.

Upvotes: 1

Abhay Chaware
Abhay Chaware

Reputation: 333

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/

Upvotes: 0

Related Questions