How to get the Full file path from URI
Use:
String path = yourAndroidURI.uri.getPath() // "/mnt/sdcard/FileName.mp3"
File file = new File(new URI(path));
or
String path = yourAndroidURI.uri.toString() // "file:///mnt/sdcard/FileName.mp3"
File file = new File(new URI(path));
android get real path by Uri.getPath()
Is it really necessary for you to get a physical path?
For example, ImageView.setImageURI()
and ContentResolver.openInputStream()
allow you to access the contents of a file without knowing its real path.
Related Topics
Image in Canvas with Touch Events
How to Change Shape Color Dynamically
How to Implement Recyclerview with Cardview Rows in a Fragment with Tablayout
Android Service Stops When App Is Closed
How to Dynamically Set the Position of View in Android
Changing Screen Brightness Programmatically (As with the Power Widget)
Nullpointerexception:Println Needs a Message in Android
How to Deploy and Execute an Application on a Device Connected to a Remote System
How to Center Text Horizontally and Vertically in a Textview
Capturing Mobile Phone Traffic on Wireshark
Change Project Name on Android Studio
Overlay Two Images in Android to Set an Imageview
Android: Getting a File Uri from a Content Uri
Meaning of Top, Ascent, Baseline, Descent, Bottom, and Leading in Android's Fontmetrics
Add and Remove Views in Android Dynamically