Search code examples
androidperformancelocal-storagehidden-files

Android - How to hide files inside the Internal/External storage?


I would like to make video/audio/pdf files hidden inside Internal/External storage in Android. Our requirement is making the files visible only in our Android application but not any other apps like Es File Explorer and not even when connecting the device to Desktop/Laptop.

I have googled it a lot and found the following ways but with few disadvantages.

Creating folder/file with prefix "." - It has the disadvantages that we cannot prevent it to be visible in some File explorer apps with the option "Show hidden files" and we cannot prevent the files from getting displayed when connected to Desktop/Laptop.

Storing the files inside App specific folder - Storing large memory files in the path returned by android.Content.Context.getFilesDir() will lead to the poor performance of the device and most of the devices will not have large internal memory size.

How to overcome the disadvantages and make our application to meet the requirement ?


Solution

  • Well hiding files to user accessable storage is not recommend without encryption.

    Youtube,Gaana, saavan, hotstar all these media related apps used to encrypt their data and stores in data location which is visible to users but they can't share or use in other ways as the data is encrypted.

    You can use CipherOutputStream and CipherInputStream for encryption and decryption of file in android.

    There are two ways through which you can achieve your goal

    Download a file and encrypt it, when you want to play that file decry-pt it in a temporary file and play it which I not recommend as it can increase the chances of data grabbing.

    if you want to play encrypted file on the fly (not decrypting it in a temp file) then you can use Libmedia library. It streams encrypted file on local host and play it from there

    Original answer : https://stackoverflow.com/a/35426842/9565955