# Load and read files on ML2

**URL:** <https://forum.magicleap.cloud/t/load-and-read-files-on-ml2/1643>\
**Category:** Unity Development\
**Created:** [March 28, 2023, 8:37pm UTC](https://forum.magicleap.cloud/t/load-and-read-files-on-ml2/1643 "2023-03-28T20:37:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefan.scharfe](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@stefan.scharfe](https://forum.magicleap.cloud/u/stefan.scharfe)\
**Post date:** [March 28, 2023, 8:37pm UTC](https://forum.magicleap.cloud/t/load-and-read-files-on-ml2/1643/1 "2023-03-28T20:37:36Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kdowney](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kdowney/32/481_2.png) [@kdowney](https://forum.magicleap.cloud/u/kdowney)\
**Post date:** [March 30, 2023, 7:52pm UTC](https://forum.magicleap.cloud/t/load-and-read-files-on-ml2/1643/2 "2023-03-30T19:52:38Z")

</div>

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-](https://support.unity.com/hc/en-us/articles/115000341143-How-do-I-read-and-write-data-from-a-text-file-)

---

<div class="post-metadata">

**Author:** ![pepone](https://avatars.discourse-cdn.com/v4/letter/p/9fc348/32.png) [@pepone](https://forum.magicleap.cloud/u/pepone)\
**Post date:** [April 3, 2023, 8:32am UTC](https://forum.magicleap.cloud/t/load-and-read-files-on-ml2/1643/3 "2023-04-03T08:32:33Z")

</div>

Hi Stefan,

I recommend using

> **[Simple Data File | Input Management | Unity Asset Store](https://assetstore.unity.com/packages/tools/input-management/simple-data-file-68025)**
>
> Get the Simple Data File package from The Lo-Fi Apocalypse, Inc. and speed up your game development process. Find this & other Input Management options on the Unity Asset Store.

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

---

<div class="post-metadata">

**Author:** ![stefan.scharfe](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@stefan.scharfe](https://forum.magicleap.cloud/u/stefan.scharfe)\
**Post date:** [April 4, 2023, 8:03am UTC](https://forum.magicleap.cloud/t/load-and-read-files-on-ml2/1643/4 "2023-04-04T08:03:24Z")

</div>

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.
