从Uri中获取真是文件路径的方法
这个方法是从网上找到的,感谢网友的无私奉献!
1 public static String getFilePathFromUri(Context context, Uri uri, 2 String[] projection, String selection, String[] selectionArgs, 3 String sortOrder) { 4 Cursor cursor = context.getContentResolver().query(uri, projection, 5 selection, selectionArgs, sortOrder); 6 int index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); 7 cursor.moveToFirst(); 8 String path = cursor.getString(index); 9 cursor.close(); 10 cursor = null; 11 return path; 12 }