tim687 tim687 - 6 months ago 56
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?



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));