Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

How to parse Json data to Android app from local file ?

Hey guys. I'm trying to parse Json data into String from local file. For my data.json file I created new folder named raw in res folder. I just don't know how to get String from that.

I was looking for solution in StackOverflow and I found this

http://stackoverflow.com/questions/19945411/android-java-how-can-i-parse-a-local-json-file-from-assets-folder-into-a-listvi

but first answer there is not working for me because I haven't got that code in Activity class and getAssets() method works only there.

So I searched for another solution and I found something here

http://stackoverflow.com/questions/9544737/read-file-from-assets

but that is confusing for me. Can anyone please show me how to parse that data from local file in normal class (not Activity class) ? Thanks

Louis Sankey
Louis Sankey
22,595 Points

Did you ever figure out an answer to this? I'm currently trying to populate a listView from a local json file and not having any luck.