I have an app which allows to select photos with an external app. Then I take the path of the photo from the uri and use it for internal actions.
When user selects a
When user selects a photo with Google Photo, if the picture is locally stored then the next code works perfectly.
Not necessarily. There is no requirement for that Uri
to respond with a _data
column to a query()
. There is no requirement for the value it returns to be useful to you (e.g., a file on internal storage or removable storage that you cannot access).
If you need the photo loaded into an ImageView
, pass the Uri
to an image-loading library, such as Picasso.
If you need the bytes of the photo, use openInputStream()
with ContentResolver
to get an InputStream
on the content identified by the Uri
. Please open and read from the InputStream
on a background thread.