Make downloaded files accessible to other apps

I am making an app in Unity for android which plays a whole bunch of videos.

Since the apk would be too big if all videos were added at build time, I download the videos at runtime and store them using: Application.persistentDataPath + "/"+filename+".mp4";

The problem is that I am playing the videos inside unity but some devices do not support this functionality (API too low or GPU doesn’t support a specific openGL extension), so in those cases my fallback solution is to use androids native player by calling: Handheld.PlayFullScreenMovie(path)

Unfortunately, the videos are stored without world-readable access and therefore the native player is not able to play the downloaded videos.

So my question is, is there a way to make these file world-readable using the path currently used? If not, is there a reliable location where I can store these files where the native player will have access to them regardless of android device?

If it’d exist a way to access non world-readable content then the device would be really a colander, the security is there for a reason and it’s to protect data. So my bet it’s not a way, as it should exactly be.

To answer your first question if you can make content of hidden / secured folders readable for other apps: No. This is a security implemented by the OS and can’t be circumvented by an ordinary App. I’m sure there are custom rom build which allow to lower or remove certain security measures, however on a vanilla Android this isn’t possible.

The second question about a reliable storage location can’t be answered that easy since there are so many different Android versions out there. It also depends on if an external storage is available. The sdcard is usually the best bet.

Most systems have an mount point called “/sdcard/” which usually maps to “/storage/emulated/0/”. On the sdcard you usually can find a subfolder “Movies”. Unity also seems to create a folder for your app at “/sdcard/Android/data/your.application.bundle.id/files/”, though it doesn’t look like Unity has a way of telling you that path. So just try and see if it’s there. It’s probably the best if you try multiple locations and if everything fails, prompt the user to manually input a folder.

ps: Unity’s folders return this for me:

  • persistentDataPath: “/data/data/your.application.bundle.id/files”
  • dataPath: “/data/app/your.application.bundle.id.apk”
  • temporaryCachePath: “/data/data/your.application.bundle.id/cache”

Since the /data folder isn’t accessible for apps you can’t do anything here. Only your application has access to your subfolder. The easiest way to construct the sdcard folder would be to take the persistentDataPath and replace “/data/data/” with /sdcard/Android/data/

pps: Keep in mind to have access to the sdcard, make sure you set the “Write Access” to “external” in the player settings / others.