How to load my text file

Hi,

I’ve read many topics on the subject but none of them helped me solve my problem.

I’m making an app for an android device and I need to use a text file to load assets into my scene. It works fine on PC but not on the target device.
I can’t use Application.persistentDataPath to find the file because I can’t side-load it, neither I can use Application.dataPath because it simply makes the app crash, and Application.streamingAssetsPath returns an inexisting directory path, according to my tests (yes, I had created a StreamingAssets folder in my project with my file in it).

I’ve tried to use Resources and load it in a TextAsset file but it always returns null. I’ve also tried to read what was in “./” (current directory) but it seems it is outside the apk.

Can anyone help me please?

List of things I tried:

string filename = Application.dataPath+"/myFolder/myFile.txt";
TextReader reader = new StreamReader(filename); 

string filename = Application.streamingAssetsPath+"/myFile.txt";
TextReader reader = new StreamReader(filename); 

TextAsset file = Resources.Load<TextAsset>("myFile"); // with my file in a Resources folder

Try using StreamingAssets folder (it has to be directly under Assets, that is YourProject/Assets/StreamingAssets) unless I’m mistaken. Then, to load the file you can use WWW.

See