Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Load JSON file in Android
public JSONObject loadJSON(Context cxt, String file) {
JSONObject json = null;
try {
InputStream is = cxt.getAssets().open(file);
int size = is.available();
byte[] buffer = new byte[size];;
String data = new String(buffer, "UTF-8");
json = new JSONObject(data);
} catch (Exception ex) {
return json;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.