例如
真实路径是 mnt/sdcard/image_1.jpg Uri 路径是 content://media/external/images/media/140 像这样
Uri photoUri =Uri.parse("content://media/external/images/media/140");
Log.d("selectedphoto",""+photoUri);
selectedImagePath = getPath(photoUri);
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
在上面的代码中,我将 Uri 转换为真实路径,但不知道如何将真实路径转换为 Uri