tim687 tim687 - 1 year ago 205
Android Question

How to get the Full file path from URI

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?

Answer Source


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


String path = yourAndroidURI.uri.toString() // "/mnt/sdcard/FileName.mp3"
File file = new File(new URI(path));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download