[SOLVED] How to get the Full file path from URI

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under
CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.


I’d like to get the full file path, from a URI. The URI isn’t a Image, but it’s a music file, but if i do it like the MediaStore Solution, it won’t work if the app user selects eg Astro as browser, instead of Music Player. How do I solve this?



String path = yourAndroidURI.uri.getPath() // "/mnt/sdcard/FileName.mp3"
File file = new File(new URI(path));


String path = yourAndroidURI.uri.toString() // "file:///mnt/sdcard/FileName.mp3"
File file = new File(new URI(path));

Answered By – Dmytro Danylyk

people found this article helpful. What about you?