/** * Get the value of the data column for this Uri. This is useful for * MediaStore Uris, and other file-based ContentProviders. * * @param context The context. * @param uri The Uri to query. * @param selection (Optional) Filter used in the query. * @param selectionArgs (Optional) Selection arguments used in the query. * @return The value of the _data column, which is typically a file path. * @author paulburke */ private static string GetDataColumn(Context context, Uri uri, string selection, string[] selectionArgs) { ICursor cursor = null; string column = "_data"; string[] projection = { column }; try { cursor = context.ContentResolver.Query(uri, projection, selection, selectionArgs, null); if (cursor != null && cursor.MoveToFirst()) { #if DEBUG DatabaseUtils.DumpCursor(cursor); #endif int column_index = cursor.GetColumnIndexOrThrow(column); return(cursor.GetString(column_index)); } } catch { } finally { if (cursor != null) { cursor.Close(); } } return(null); }