Rendy
Rendy

Reputation: 5698

Prevent users to view/delete file in sdcard

I have an internal app that can be distributed to company's users.

The admin can put a file to the device in specified folder in sdcard but don't want the users can view/delete it. What is the best way/concept to achieve it? Have tried researching it but still don't find good solution.

Upvotes: 2

Views: 2731

Answers (2)

Aleks G
Aleks G

Reputation: 57326

I'm not sure it's even possible. The user can always take the SD card out, put it into a card reader and view/delete it that way. If your app relies on preventing access to a file on SD, then I'd say your design is flawed.

According to the android documentation, you should store private data in the internal storage and store public data in the external storage - have a look at the storage options documentation for more info.

If you require to store/read files that users shouldn't be able to access other than through you app, then you should store these files in the local directory for the app (which would normally be under /data/data/your.app.package). Use openFileInput and openFileOutput methods on a Context to read/write such files.

Upvotes: 8

Brajendra Pandey
Brajendra Pandey

Reputation: 2274

If your application uses some files then put these file into application's assets folder. If file present in sdcard then any one can view and delete.

Upvotes: 1

Related Questions