- Home /
Accesing StreamingsAssets in android (LitJson)
I have seen there are a couple of posts like these, but none of them helped me :(
I am trying to make an enemy database for my game, and I'm using LitJson, the code needs to find the streamingassets file on my Android phone, but when i make it an apk, it dosent work. This is the line of code that dosen't work on Android:
itemData = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/StreamingAssets/Items.json"));
So my question is, how do I acces the streamingassets folder in my phone?
Answer by Naphier · Oct 20, 2016 at 03:13 AM
https://docs.unity3d.com/Manual/StreamingAssets.html
On Android, use: path = "jar:file://" + Application.dataPath + "!/assets/"; On Android, the files are contained within a compressed .jar file (which is essentially the same format as standard zip-compressed files). This means that if you do not use Unity’s WWW class to retrieve the file, you need to use additional software to see inside the .jar archive and obtain the file.
Your answer
Follow this Question
Related Questions
LitJson not working correctly 2 Answers
Parse JSON with LitJSON 2 Answers
How to read an int array using LitJson? 1 Answer