1. 程式人生 > >Convert file: Uri to File in Android

Convert file: Uri to File in Android

What you want is…

new File(uri.getPath());

… and not…

new File(uri.toString());

NOTE: url.toString() return a String in the format: "file:///mnt/sdcard/myPicture.jpg", whereas url.getPath() returns a String in the format: "/mnt/sdcard/myPicture.jpg",