public static String getDataColumn ( Context context , Uri uri , String selection , String [ ] selectionArgs ) { Cursor cursor = null ; final String column = "_data" ; final String [ ] projection = { column } ; try { cursor = context . getContentResolver ( ) . query ( uri , projection , selection , selectionArgs , null ) ; if ( cursor != null && cursor . moveToFirst ( ) ) { final int index = cursor . getColumnIndexOrThrow ( column ) ; return cursor . getString ( index ) ; } } finally { if ( cursor != null ) cursor . close ( ) ; } return null ; }
Get the value of the data column for this Uri . This is useful for MediaStore Uris and other file - based ContentProviders .