简体   繁体   中英

How to hide media files on SD card in Android?

I am developing one android application, here I'm downloading some media files and I want to keep the files as private to my application. The files size are very large, so it's not possible to store it in internal storage because it may affect phone storage and will create memory issues.

Encryption and decryption of the media files takes more time to process. Is it possible to store the files as safe in external storage. The files I want to store should not be accessed by another applications and when connected to pc it should not be visible.

Any help would be appreciated. Thanks in advance.

// get the path to sdcard
File sdcard = Environment.getExternalStorageDirectory();
// to this path add a new directory path
File dir = new File(sdcard.getAbsolutePath() + “/your-dir-name/”);
// create this directory if not already created
dir.mkdir();
// create the file in which we will write the contents
File file = new File(dir, “My-File-Name.txt”);
FileOutputStream os = outStream = new FileOutputStream(file);
String data = “This is the content of my file”;
os.write(data.getBytes());
os.close();

Sorry, you cannot. Data stored in external storage is world-readable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM