Android examples for Graphics:Bitmap File
load From Assets
import java.io.IOException; import java.io.InputStream; import android.app.Activity; import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { public static Bitmap loadFromAssets(Activity activity, String name, int sampleSize, Bitmap.Config config) { AssetManager asm = activity.getAssets(); try {/*from w w w .ja v a 2 s. c o m*/ InputStream is = asm.open(name); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = sampleSize; options.inPreferredConfig = config; try { Bitmap bitmap = BitmapFactory.decodeStream(is); is.close(); return bitmap; } catch (OutOfMemoryError e) { } } catch (IOException e) { e.printStackTrace(); } return null; } }