get Image From Sys Gallery - Android Graphics

Android examples for Graphics:Image File

Description

get Image From Sys Gallery

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;

import android.net.Uri;
import android.provider.MediaStore;

public class Main {

    public static String getImageFromSysGallery(Activity activity,
            Intent data) {//from   ww  w.j  av a  2s  . c  o  m
        Uri uri = data.getData();
        String[] proj = { MediaStore.Images.Media.DATA };
        Cursor cursor = activity.managedQuery(uri, proj, null, null, null);
        int index = cursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        String filepath = cursor.getString(index);
        return filepath;
    }
}

Related Tutorials