This question was
closed Feb 26, 2018 at 03:04 AM by
Ginxx009 for the following reason:
Solved
Question by
Ginxx009 · Dec 11, 2017 at 03:43 AM ·
androidunity 5jsonstreamingassets
Loading JSON from StreamingAssets on android(c#)
Is there a way i can load my json file from streaming assets on android . I can't find any references about it . Here's my code so far
// Load 2 (StreamingAssets).
public static string LoadJsonFromStreamingAssets(string path_with_extention_under_streaming_assets_folder)
{
string json = null;
try
{
#if UNITY_ANDROID
# else
string full_path = string.Format("{0}/{1}", Application.streamingAssetsPath, path_with_extention_under_streaming_assets_folder);
StreamReader reader = new StreamReader(full_path);
json = reader.ReadToEnd().Trim();
reader.Close();
#endif
}
catch (Exception e)
{
Debug.LogWarningFormat("Failed to Load.\n{0}\n{1}", e, path_with_extention_under_streaming_assets_folder);
}
return json;
}
On my else part which indicates that if it a windows or any other platform that code will be executed . Now for my android i don't know where to start . I just can't find any references at all .
By the way on my logcat here is the error.
System.IO.DirectoryNotFoundException: Could not find a part of the path "/jar:file:/data/app/com.steet383.rh.google-1/base.apk!/assets/notice.json".
I hope someone can help me with my problem.
Comment