Search code examples
unity-game-engineoculusoculusquest

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);
}

Solution

  • 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.