How to get content URI from file address on Android

Asked 2 years ago, Updated 2 years ago, 34 views

/sdcard/cats.jpg <- I know the absolute address of the image like this. How do I know the content URI of this file?

I even downloaded the image file from my code and saved it in a specific folder. If you want to read an image using the path where my file is currently stored in Image View, you can read it with bitmap, but it's too slow, so if you change this path to contenturi, it's faster and easier to import it with the method ImageView.setImageUri(uri), but I don't know how to change it to contenturi. Please let me know.

image android

2022-09-21 19:45

1 Answers

ImageView.setImageURI(Uri.fromFile(new File("/sdcard/cats.jpg"))); This one ImageView.setImageURI(Uri.parse(new File("/sdcard/cats.jpg").toString())); Do it like this.


2022-09-21 19:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.