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