get Picture Path By Uri - Android Network

Android examples for Network:Uri

Description

get Picture Path By Uri

Demo Code


//package com.java2s;

import android.content.Context;
import android.database.Cursor;

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

public class Main {
    private static String getPicPathByUri(Uri uri, Context context) {
        String path = "";
        Uri imageUri = uri;//  ww w.  ja  v a2s.  co  m
        Cursor cursor = context.getContentResolver().query(imageUri, null,
                null, null, null);
        if (cursor.moveToNext()) {
            path = cursor.getString(cursor
                    .getColumnIndex(MediaStore.Images.Media.DATA));

        }
        return path;
    }
}

Related Tutorials