https://kotlinlang.org logo
a

Aslam Hossin

01/07/2020, 2:18 AM
Copy code
How to convert this Uri /storage/emulated/0/DCIM/Camera/IMG_20200106_121447.jpg  to File ?
google 2
stackoverflow 2
j

Jamie Craane

01/07/2020, 7:41 AM
What do you want to do with it? You can create an InputStream from the Uri like:
Copy code
InputStream is = context.getContentResolver().openInputStream(uri);
and then copy the contents to a File in the application cache or temp folder for example.
p

Paul Woitaschek

01/07/2020, 11:04 AM
Copy code
File(path)
g

gildor

01/14/2020, 11:15 PM
File(path) will fail if you don't have SD card permissions and will 100% fail on Android 10, use only content resolver as Jamie recommended
40 Views