Saving data to file

Give us as much detail as possible regarding the issue you’re experiencing:

Unity Editor version: 2022.3.61f1
ML2 OS version:2.6.0-pre.R15
Unity SDK version:
Host OS: Windows

I have problem with getting data from magicLeap 2 app. my app is calculating come angles based on positions of aruco markers. I want to save this data to csv file. I have created a class to obtain this data and save it to file. in other script I’m creating file and from debugger everything looks like the file has been created and has data in it but I cannot download this file from my glasses.

To download data I’m using adb pull but it looks like I do not have permission to get into ./file directory:

C:\Users\LENOVO>adb shell “ls /data/data/com.UnityTechnologies.com.unity.template.urpblank/file/”
ls: /data/data/com.UnityTechnologies.com.unity.template.urpblank/file/: Permission denied

Is there any other method to obtain data from your app? The worst scenario is using websocket but I’m already downloading data from websocket so I’d like not to clog it with too much information.

Hey @tanior0803 ,

First, let’s try verifying the save path for the file and ensure it’s the correct path you are looking in when attempting to find/load the file.

If you are saving the file using the path Application.persistentDataPath + "file name.csv", then the path you should be looking for the file in is /storage/emulated/0/Android/data/{your project package name}/files/file name.csv

If the issue you’re experiencing is permissions related, it most likely means you’re attempting to save the file outside of scoped storage. If that is the case, you will need to make sure you have WRITE_EXTERNAL_STORAGE permissions which you can request via script at runtime.

Here’s an example of a script that requests external storage writing

using UnityEngine;
using System.Collections;
using UnityEngine.Android;

public class ExampleScript : MonoBehaviour
{
    void Start()
    {
        if(!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
        {
            Permission.RequestUserPermission(Permission.ExternalStorageWrite);
        }
    }
}

Let me know if this helps or if you need anymore assistance!

Best,
Corey