Search code examples
androidandroid-external-storagedata-storage

Is there a way to restrict access to the files downloaded to external storage apart from the parent app


My requirement is my app will download an image and a video (15MB) to the external storage of the app. And I doesn't want gallery or any other app apart from mine access these files. I am thinking of below two solutions please suggest your opinions and suggest is there any other way.

  1. Considering of encryting the images and videos downloaded.
  2. Downloading the files to .nomedia folder to make sure at least media scanner will not scan it.

Solution

  • IF you make it hidden folder like shown bellow apps like Gallery will ignore these folders. That's the only way that I think this can be done. The reason that this will work fine is because Android is multi user Linux system.

    File folder = new File(Environment.getExternalStorageDirectory(), ".hiddenFolder");
    folder.mkdir();
    

    Hope that helps!