Skip to content

Instantly share code, notes, and snippets.

@arielmagbanua
Created January 27, 2016 04:45
Show Gist options
  • Save arielmagbanua/e9b5b9317fcf12d5c8ca to your computer and use it in GitHub Desktop.
Save arielmagbanua/e9b5b9317fcf12d5c8ca to your computer and use it in GitHub Desktop.
Reading local json from asset folder in android
public String loadJSONFromAsset() {
String json = null;
try {
InputStream is = getAssets().open("file_name.json");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
return json;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment