Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shishirthedev/49690dd1b555a61cc8d04a29a94721da to your computer and use it in GitHub Desktop.
Save shishirthedev/49690dd1b555a61cc8d04a29a94721da to your computer and use it in GitHub Desktop.
public String getAssetJsonData(Context context, String jsonFileName) {
String json = null;
try {
InputStream is = context.getAssets().open(jsonFileName + ".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;
}
Log.e("data", json);
return json;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment