Android Context Get getRealPathFromURI(Context context, Uri contentUri)

Here you can find the source of getRealPathFromURI(Context context, Uri contentUri)

Description

get Real Path From URI

Declaration

public static String getRealPathFromURI(Context context, Uri contentUri) 

Method Source Code

//package com.java2s;
import android.content.Context;

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

public class Main {
    public static String getRealPathFromURI(Context context, Uri contentUri) {
        String[] proj = { MediaStore.Images.Media.DATA };
        Cursor cursor = context.getContentResolver().query(contentUri,
                proj, null, null, null);
        int column_index = cursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();/*w ww . j  a  v a2 s . co  m*/
        String path = cursor.getString(column_index);
        cursor.close();
        return path;
    }
}

Related

  1. getPath(Context context, Uri uri)
  2. getPathFromUri(Context context, Uri uri)
  3. getPermissionLabel(Context context, String permission)
  4. getPreferences(Context context, String campaignUrn)
  5. getPrefs(Context context)
  6. getReceiverMetaData(Context context, Class receiverClass, String key)
  7. getRequestQueue(Context ctx)
  8. getResDimen(Context context, int resId)
  9. getResourcesPath(Context context, String url)