Here you can find the source of getOriginalFilePath(Context context, Uri imageUri)
Parameter | Description |
---|---|
context | the context |
imageUri | the image uri |
public static String getOriginalFilePath(Context context, Uri imageUri)
//package com.java2s; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore.MediaColumns; public class Main { /**/*from w w w .j a v a 2 s .co m*/ * Gets the original file path. * * @param context * the context * @param imageUri * the image uri * @return the original file path */ public static String getOriginalFilePath(Context context, Uri imageUri) { if (imageUri.getScheme().equals("file")) { return imageUri.getPath(); } String[] filePathColumn = { MediaColumns.DATA, MediaColumns.DATA }; Cursor cursor = context.getContentResolver().query(imageUri, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); return cursor.getString(columnIndex); } }