Android Asset Load loadAsset(Context context, String asset)

Here you can find the source of loadAsset(Context context, String asset)

Description

load Asset

License

Open Source License

Declaration

public static byte[] loadAsset(Context context, String asset) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

import android.util.Log;
import java.io.IOException;
import java.io.InputStream;

public class Main {
    private static final String TAG = "FeedMe";

    public static byte[] loadAsset(Context context, String asset) {
        byte[] buffer = null;
        try {//from  w  ww  .  j a v  a  2s .co  m
            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;
    }
}

Related

  1. loadJSONAsset(Context context, String asset)
  2. openXMLFile(String name, Context ctx)