Load and read files on ML2

Give us as much detail as possible regarding the issue you're experiencing.

Unity Editor version: 2021.3.18f1
ML2 OS version: 1.2.0-dev1
MLSDK version: 1.4.0
Host OS: Windows

I would like to read a file that I save on the device later. Unfortunately, there are no examples for the ML2. Where can I save files in the file system so that the programme can access them later? How can I read this file, line by line or as a whole?

Hi @stefan.scharfe. Please see Unity's documentation here: https://support.unity.com/hc/en-us/articles/115000341143-How-do-I-read-and-write-data-from-a-text-file-

Hi Stefan,

I recommend using

Currently I am using a standard .txt files that you can put in the
storage/emulated/self/primary/Android/data/ <com.yourML2app folder> directly via ML2hub
to load the configuration for my app. If you want to save and load localy you could
use persistentDataPath on android - just change this:

// dataFileAssoc.cs

public virtual bool load(bool populate = true) 
{

#if UNITY_EDITOR
fileName = Application.dataPath + "/" + fileName;
#else
fileName = Application.persistentDataPath + "/" + fileName;
#endif

The problem was not open and parse the file, but to find a folder the application has granted acesss to. I found by trial and error that using the obb folder of the application seems to be a good solution. @kdowney maybe you could add something about loading external files to the documentation in the developer portal. The documentation you mentioned is good, but some explanation about the file system would be helpful, especialy for android-noobs like i am.

1 Like