- Home /
Accessing Videos on Android Device
I am creating an application that allows a user to queue up videos that they would like to watch within the application. On Mac, in order to access the videos, it is as simple as:
DirectoryInfo dir = new DirectoryInfo(VIDEO_PATH);
FileInfo[] info = dir.GetFiles("*.*");
However, when I build on the Android device itself, it is throwing an error: "UnauthorizedAccessException: Access to path '/storage/emulated/0/DCIM/VR Videos' is denied."
How do I get it to allow me into that folder? I don't want to include all the videos in the apk itself as it would be huge and I want to be able to add new videos without needing to re-export another apk.
did you find any solution for this specific path problem
Answer by Legend_Bacon · Feb 20, 2018 at 07:13 PM
Hello there,
On Android things get a little bit more complicated. GetFiles() is not guaranteed to work as intended, as many files and folders get zipped into a .jar. THIS POST explains it a little more in details.
Usually, the best solution is to use Application.PersistentDataPath. You may need to rewrite a little bit of code, but it works on both Android and Windows without issues. It should also just run on Mac, although I've never tested myself to give you a 100% on that.
I hope that helps!
Cheers,
~LegendBacon
Hey @Legend_Bacon would that mean I would need to place all my videos in the PersistentDataPath? I am trying to avoid having the videos directly associated to the .apk itself (that way they won't get zipped into a .jar), and I would like to place the videos anywhere I'd like on the phone and be able to grab them from within the app. Any ideas?
Pretty much. I am guessing you download the videos, so just save them to Application.PersistentDataPath ins$$anonymous$$d of what you are currently doing. Also just in case, THIS mayhelp you.
Cheers,
~LegendBacon
Your answer
Follow this Question
Related Questions
android browse and read text files 1 Answer
downloading file, saving on android 1 Answer
Android: Writing persistent data to SD Card 2 Answers
StreamingAssets folder ANDROID 0 Answers