Reputation: 1569
I need to use bundled json in my application.So i added my json file under assets folder.How to write code for using this ?Please help...
Upvotes: 0
Views: 41
Reputation: 5068
you first need to read your json from asset folder
InputStream is = appContext.getAssets().open("myJson.json");
int size = is.available();
buffer = new byte[size];
is.read(buffer);
is.close();
String bufferString = new String(buffer);
and then you can do
JSONObject obj = new JSONObject(bufferString);
and now obj
contain your json
.
Upvotes: 2