What you want is…
new File(uri.getPath());
… and not…
new File(uri.toString());
Notes
- For an
android.net.Uriobject which is nameduriand created exactly as in the question,uri.toString()returns aStringin the format"file:///mnt/sdcard/myPicture.jpg", whereasuri.getPath()returns aStringin the format"/mnt/sdcard/myPicture.jpg". - I understand that there are nuances to file storage in Android. My intention in this answer is to answer exactly what the questioner asked and not to get into the nuances.