Android Utililty Methods Asset Load

List of utility methods to do Asset Load

Description

The list of methods to do Asset Load are organized into topic(s).

Method

byte[]loadAsset(Context context, String asset)
load 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) {
...
JSONObjectloadJSONAsset(Context context, String asset)
load JSON Asset
String jsonString = new String(loadAsset(context, asset));
JSONObject jsonObject = null;
try {
    jsonObject = new JSONObject(jsonString);
} catch (JSONException e) {
    Log.e(TAG, "Failed to parse JSON asset " + asset + ": " + e);
return jsonObject;
...
InputStreamopenXMLFile(String name, Context ctx)
open XML File
AssetManager assets = ctx.getAssets();
InputStream open = assets.open(name);
return open;