private String getRealPathFromURI ( String contentURI ) { Uri contentUri = Uri . parse ( contentURI ) ; Cursor cursor = mContext . getContentResolver ( ) . query ( contentUri , null , null , null , null ) ; if ( cursor == null ) { return contentUri . getPath ( ) ; } else { cursor . moveToFirst ( ) ; int index = cursor . getColumnIndex ( MediaStore . Images . ImageColumns . DATA ) ; Log . e ( LOG_TAG , String . format ( "%d" , index ) ) ; String str = cursor . getString ( index ) ; cursor . close ( ) ; return str ; } }
Gets a valid path from the supply contentURI