Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.graphics.BitmapFactory; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; public class Main { public static Bitmap getBitmapByPath(String filePath) { return getBitmapByPath(filePath, null); } public static Bitmap getBitmapByPath(String filePath, BitmapFactory.Options opts) { FileInputStream fis = null; Bitmap bitmap = null; try { File file = new File(filePath); fis = new FileInputStream(file); bitmap = BitmapFactory.decodeStream(fis, null, opts); } catch (FileNotFoundException | OutOfMemoryError e) { e.printStackTrace(); } finally { try { if (fis != null) { fis.close(); } } catch (Exception e) { e.printStackTrace(); } } return bitmap; } }