Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write file to Oculus Quest internal storage

I am trying to write a .csv file to save the user's actions and collect it later from the device. I have tried on my computer and it works but I can't seem to get it to work in the Oculus Quest.

My code goes like:

using (var writer = new StreamWriter($"{Application.persistentDataPath}/{_fileName}"))
using (var csv = new CsvWriter(writer))
{
    csv.WriteRecords(metrics);
}
like image 532
Marcelo Nunes Avatar asked Nov 27 '25 23:11

Marcelo Nunes


1 Answers

Try the base path /mnt/sdcard/. So you will get something like:

using (var writer = new StreamWriter($"/mnt/sdcard/{_fileName}"))
using (var csv = new CsvWriter(writer))
{
    csv.WriteRecords(metrics);
}

To allow your program to use the internal storage you need to properly configure the Build Settings. This can be done by going to File->Build Settings->Player Settings...->Other Settings->Write Permissions and change it to External(SDCard) (I did this in Unity 2018.4.11f1)

Also, beware when running the application on your device, if no pop-up asking for write permission shows up try going to Library to run your application again.

like image 130
Marcelo Nunes Avatar answered Dec 02 '25 04:12

Marcelo Nunes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!