Java tutorial
//package com.java2s; import android.content.Context; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; import java.io.InputStream; public class Main { private static final String DIR_BOARDS_ASSETS = "Boards"; public static JSONObject getBoardJSONFromAssets(Context context, String pathNameFile) { String output = loadJSONFromAsset(context, pathNameFile); JSONObject jsonObject = null; try { jsonObject = new JSONObject(output); } catch (JSONException e) { e.printStackTrace(); } return jsonObject; } private static String loadJSONFromAsset(Context context, String pathNameFile) { String output = null; try { InputStream is = context.getAssets().open(DIR_BOARDS_ASSETS + "/" + pathNameFile); int size = is.available(); byte[] buffer = new byte[size]; is.read(buffer); is.close(); output = new String(buffer, "UTF-8"); } catch (IOException ex) { ex.printStackTrace(); return null; } return output; } }