I have JSON file in assets and I'm trying to read it in my MainActivity method:
private static List<JSONObject> getJSONArray(Context context) {
JSONArray myJSONarr=new JSONArray();
try
{
AssetManager am = context.getAssets();
InputStream is = am.open("chineesecardsdata.json");
String resultJson = is.toString();
is.close();
Log.d("mainActLog","file read ok: "+resultJson);
try {
}
catch (JSONException e)
{
}
}
catch(
IOException e)
{
Log.d("mainActLog","file read fail");
}
}
In log I have:
file read ok: android.content.res.AssetManager$AssetInputStream@b123fb4