how put txt file into android package

I have programme that have to read txt file, on coputer it work but on android don’t, I don’t know how to locate my txt file’s that they I coud read the with path. I was tried to locate txt file in Resources file, first I have using System.IO; and path:

string path_first_level= @"Resources/first_level.txt";

the I use ReadAllLines:

first_level = System.IO.File.ReadAllLines(path_first_level);

ReadAllLines is best for me becaus it return a table when every line is an object in table so I navigate in txt with this, on computer it works, what should I change with path to use it on android

Since you did place your text files in the resources folder, I assume you did read something about this.

However, the way you try to access these files is not the Unity way. In fact, this probably won’t work if you would make a build for windows/mac either (unless you manually place the files at the given path after you build). Only in the editor this should work.

By reading the Description of the Resources page you can see how you should acces your data inside the Resources folder.

In your case, sinse you are trying to read a text file. Loading a TextAsset is probably what you want to do. Note that the path parameter is not the full path. In your case “first_level.txt” will probably do the trick (not sure if the .txt is needed, but I’m sure you’ll be able to figure that out :p)

TextAsset asset = Resources.Load<TextAsset>("YourPathHere");

As for why you ca’t access your files using System.IO. This is because your files don’t exist. Or at least, not in the same way as they do inside your project. For more information on this, this wiki article covers this. (the “Resources” part)