Android Cursor Read getPhotoPathByLocalUri(Context context, Intent data)

Here you can find the source of getPhotoPathByLocalUri(Context context, Intent data)

Description

get Photo Path By Local Uri

Declaration

public static String getPhotoPathByLocalUri(Context context, Intent data) 

Method Source Code

//package com.java2s;

import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;

public class Main {

    public static String getPhotoPathByLocalUri(Context context, Intent data) {
        Uri selectedImage = data.getData();
        String[] filePathColumn = { MediaStore.Images.Media.DATA };
        Cursor cursor = context.getContentResolver().query(selectedImage,
                filePathColumn, null, null, null);
        cursor.moveToFirst();/*from   w  w  w  . ja  va  2s . c om*/
        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String picturePath = cursor.getString(columnIndex);
        cursor.close();
        return picturePath;
    }
}

Related

  1. getLong(String column)
  2. getLong(String columnName)
  3. getPath(Context context, Uri uri)
  4. getString(Cursor c, String column)
  5. getString(String column)
  6. getIntFromCursor(Cursor cursor, String columnName)
  7. getStringFromCursor(Cursor cursor, String columnName)
  8. getPositionById(Cursor cursor, long theTargetId)
  9. newClosedCursor()