access to oculus 2 local video/images from unity

hello, i want to ask how can i access to some videos and image url which are located in my oculus 2 local storage to use them in unity, i used to access by url /sdcard/Android/…/…/…mp4 but its not working anymore

having the same issue at the moment, worked fine before

This is because the Quest OS v53 now uses Android 12, which limits the way apps can access storage. From the developers of Polysketch:

  • No Access
    — /sdcard/Polysketch/
  • Can create folders, but not files
    — /sdcard/Android/Polysketch/
  • Full folder & file creation
    — /sdcard/Andoird/Android/data/com.PolysketchLLC.Polysketch/files (Application.persistentDataPath)
    — /sdcard/Download/Polysketch/ ----- not very safe as users will arbitrarily delete-all here if running out of space
    — /sdcard/Documents/Polysketch/ ----- seems like the best option. Easy user access, and we can read each other’s save locations if we wish to.

How to update -
Setting the flag preserveLegacyExternalStorage to true in the manifest will allow you to read & write from sdcard/whatever/ if the app is installed as an update to an older version. On clean installs, this flag is ignored. So this flag won’t grant us access indefinitely, but will let us read old save files and move them to the new preferred spot. AndroidManifest.xml

3 Likes

h

hello sir thanks for responding, I didn’t quit understood how to fix it, i’ve added android reserveLegacyExternalStorage=“true” to the manifest but I couldn"t build the project

100000001218704--1121384--clear.png

My post above shows which locations are allowed to access, namely either Application.persistentDataPath, Downloads, or Documents. You can get these folders like this:

AndroidJavaObject downloadFolder = environment.CallStatic<AndroidJavaObject>("getExternalStoragePublicDirectory", environment.GetStatic<AndroidJavaObject>("DIRECTORY_DOWNLOADS"));
string folderPath = downloadFolder.Call<string>("getAbsolutePath");

I think Thomas was referring to android:preserveLegacyExternalStorage="true"

while the system thought that was an emoji

1 Like

Sorry for newbie question, but what’s the environment in that code?

I’m using Unity and Quest 2 and want to read a jpg picture from the persistent data path, but it won’t load on Quest 2. Same code works on PC and debug messages tell that 1.jpg file is in the directory both on PC and Quest 2.

EDIT: Man, Chat-GPT is excellent for these kind of small easy questions. I pasted those two lines and asked what’s the “environment”, and it explained everything, but I paste only the relevant part:
environment: Presumably, this is an instance of AndroidJavaClass that represents the Android environment. This could be obtained by calling new AndroidJavaClass(“android.os.Environment”), for example.