I’m trying to load Json file from streamingAssetsPath in Android build, and my code is blow:
IEnumerator loadPlayerData()
{
dataPath = Path.Combine(Application.persistentDataPath, "PlayerDatabase.txt");
filePath = Path.Combine(Application.streamingAssetsPath, "PlayerDatabase.json");
if (!File.Exists(dataPath))
{
#if UNITY_ANDROID
UnityWebRequest www = UnityWebRequest.Get(filePath);
yield return www.SendWebRequest();
string jsonString = www.downloadHandler.text;
File.WriteAllText(dataPath, jsonString);
if (www.isNetworkError)
{
Debug.Log("Error: " + www.error);
}
else
{
Debug.Log("Received: " + www.downloadHandler.text);
}
#endif
}
and it logs “Error: Cannot connect to destination host”, I can’t load anything from it. I don’t know where is wrong.