Heya all,
I’m trying to write a .csv file and folder to the Quest2 headset so I can access it on the storage of the headset. I’ve been trying several methods I’ve found online without success. There seems to be several ways of targeting the storage none of which I’ve managed success with.
It might be permissions. Some articles have mentioned it should pop up a access dialogue for the user (but I think that may be for reading rather than writing) which my app definitely doesn’t.
Project Settings > Player > Other > Write Permissions: External (SDCard)
The UnityManifest file has:
Here is the core bits of code I’ve tried
writer = new StreamWriter($"/mnt.sdcard/VirtualRoomSwayData/Participant.csv");
writer = new StreamWriter("/storage/extSdCard/VirtualRoomSwayData/Participant.csv");
writer = new StreamWriter("/storage/emulated/0/VirtualRoomSwayData/Participant.csv");
Thanks JoeStrout. I just tried your code and also no file has been written. I tried with Permissions set to Internal and External SD Card, resetting the USB connection and restarting application from the headset (as I’ve read that can fix some things). Still nothing was written. Any other ideas?
No. I use that exact code all the time, and it works for me. Did you get an exception? Or could it be you just can’t find the file (i.e. looking in the wrong place)?
I’ve found that the Windows explorer sometimes displays stale data. (Deleted files were still shown, or created files were not shown even when they were there.) Replugging the headset usually fixes it, but that definitely caused me some unnecessary minutes of head-sratching before. Not sure whether that’s the issue here though.
No exceptions or errors just no file. I’ve looked both at the “internal” path and in the external locations and there are definitely no files ever written.
I want to write files to a folder on the Quest 2 when it is plugged in which is the SD Card from my understanding. I can’t even create a new directory there.
I’ve also checked Android>data>“apk build folder”>files
Maybe we misunderstood. The solution given before works when executed in an app on-device.
Are you’re trying to write files to the Quest from the Unity Editor or a Windows application?
I have tried both paths:
/sdcard/Download/
/storage/emulated/0/
with internal, then external permissions set within player settings, plus an android manifest with read and write access to external and it still says that “access denied” when i try to read from the quest 2.
THAT WAS IT, the Android 9 fixed the issue for me.
In case someone else has the same issue:
Select Android Pie 9
Internal Access Require
Write Permission External (SDCard)
Yeah I can also confirm this works. It’s weird because from what I remember it used to work just by setting Write Permission External (SDCard) from Editor, but apparently now you have to also add the permission manually to manifest
None of the proposals in this thread to access the folders inside the /sdcard directory worked for me, the only thing that worked for me is access to persistent data but only in that directory, I can’t access Pictures or Movies directories.
The only way I could do to grant read permissions to the /sdcard directory and subdirectories to my application is by manually granting the permission as follows:
adb devices
adb shell
pm grant <com.company.proyectName> android.permission.READ_EXTERNAL_STORAGE
<understanding that “com.company.projectName” is the name of the application / package**>**
If you don’t know the package name of your application you can do the following to get a list of all installed applications / packages: pm list packages Maybe it will help someone else.