Load text file on Streaming assets in Android

On unity documents, Streaming assets are pressed to jar file.

I played my game on android, My text file on streaming assets did not be loaded.

string path = Application.streamingAssetsPath + "/" + filename;
		if(Application.platform == RuntimePlatform.Android)
		{
			path =  "jar:file://" + Application.dataPath + "!/assets/" + filename;
		}

		if (File.Exists(path))
		{
			FileStream file = new FileStream (path, FileMode.Open, FileAccess.Read);
			StreamReader sr = new StreamReader( file );
			
			string str = null;
			str = sr.ReadLine ();
			
			sr.Close();
			file.Close();
			
			return str;
		}
		
		else
		{
			return null;
		}

this is my code of read file.

I need your help T.T

Hi,

I think the path Application.streamingAssetsPath + "/" + filename; is still valid on android, you don’t need to use something else to access your data on android.

Anyway, try to read your file using a WWW instead of using a filestream, it should works better with unity.

it is always better to use with path.combine

string filename = "";
Path.Combine(Application.streamingAssetsPath, filename);

Here you go:

@sanmn19 bro/sir, can you please help me? I am stuck in this… I am trying to access streaming assets in an apk and failing for 3 days… If you could help it would be very kind of you.