Here you can find the source of assetAsByteArray(Resources res, String path)
public static byte[] assetAsByteArray(Resources res, String path) throws IOException
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import android.content.res.Resources; public class Main { /**/*from w ww .j a v a 2 s . c o m*/ * Load an asset from a resource and return the content as byte array. */ public static byte[] assetAsByteArray(Resources res, String path) throws IOException { InputStream is = res.getAssets().open(path); ByteArrayOutputStream buf = new ByteArrayOutputStream(); byte[] temp = new byte[1024]; int read; while ((read = is.read(temp)) > 0) { buf.write(temp, 0, read); } is.close(); return buf.toByteArray(); } }