Java tutorial
//package com.java2s; import android.content.ContentResolver; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import java.io.InputStream; public class Main { public static Bitmap decodeUriAsBitmap(Context context, Uri uri, BitmapFactory.Options options) { Bitmap result = null; if (uri != null) { ContentResolver cr = context.getContentResolver(); InputStream inputStream = null; try { inputStream = cr.openInputStream(uri); result = BitmapFactory.decodeStream(inputStream, null, options); inputStream.close(); } catch (Exception e) { e.printStackTrace(); } } return result; } }