Here you can find the source of loadJSONAsset(Context context, String asset)
public static JSONObject loadJSONAsset(Context context, String asset)
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.util.Log; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; import java.io.InputStream; public class Main { private static final String TAG = "FeedMe"; public static JSONObject loadJSONAsset(Context context, String asset) { String jsonString = new String(loadAsset(context, asset)); JSONObject jsonObject = null;//from w w w. j a va 2s . c o m try { jsonObject = new JSONObject(jsonString); } catch (JSONException e) { Log.e(TAG, "Failed to parse JSON asset " + asset + ": " + e); } return jsonObject; } public static byte[] loadAsset(Context context, String asset) { byte[] buffer = null; try { InputStream is = context.getAssets().open(asset); int size = is.available(); buffer = new byte[size]; is.read(buffer); is.close(); } catch (IOException e) { Log.e(TAG, "Failed to load asset " + asset + ": " + e); } return buffer; } }