Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create private folder in sdcard

Tags:

android

sqlite

My application is used for security purpose. so, from my application user captures photos that all photos are stored in a folder that folder should not access from any other application and should not give access when devices connect to computer system. If user wants to view these images he should access only from my application.

like image 429
B Bhanu Chander Avatar asked May 28 '12 06:05

B Bhanu Chander


2 Answers

According to this guide, you can save files directly on the device's internal storage. By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed. For example:

String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();

MODE_PRIVATE will create the file (or replace a file of the same name) and make it private to your application. Other modes available are: MODE_APPEND, MODE_WORLD_READABLE, and MODE_WORLD_WRITEABLE.

like image 150
Ant4res Avatar answered Nov 14 '22 09:11

Ant4res


The only way, AFAIK is to encrypt the files that you store. There is no way to prevent users mount the sdcard to access every file stored in it.

like image 32
Blackbelt Avatar answered Nov 14 '22 11:11

Blackbelt