/** * 通过uri获取文件的绝对路径 * * @param uri * @return */ private String getAbsoluteImagePath(Uri uri) { String imagePath = ""; String[] proj = { MediaStore.Images.Media.DATA }; Cursor cursor = MainActivity.this.managedQuery(uri, proj, // Which null, // WHERE clause; which rows to return (all rows) null, // WHERE clause selection arguments (none) null); // Order-by clause (ascending by name) if (cursor != null) { int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); if (cursor.getCount() > 0 && cursor.moveToFirst()) { imagePath = cursor.getString(column_index); } } return imagePath; }