I have a content URI in the form of "content://media/external/images/media/175". I am trying to find the absolute path of the image in question in order to send the file in a request. Is there any way to accomplish this?
1
-
1You can't convert content URIs to file URIs (a content URI does not necessarily mean you have access to the underlying file). What exactly do you mean by 'in order to send the file in a request'? Include the code you want to run.ianhanniballake– ianhanniballake2016-06-16 21:23:46 +00:00Commented Jun 16, 2016 at 21:23
Add a comment
|
1 Answer
I am trying to find the absolute path of the image
A Uri is not a file. You cannot convert arbitrary Uri values to some filesystem path that you can access. Those Uri values might point to:
- A file on removable storage
- A file on internal storage of some other app
- A file that has not yet been downloaded, but will be downloaded on the fly by the
ContentProvider - A file that has been encrypted and will be decrypted on the fly by the
ContentProvider - A
BLOBin a database - Content that will be generated dynamically, the way this Web page is
- And so on
in order to send the file in a request
Use a ContentResolver and openInputStream() to get an InputStream to use in your request. If whatever API you are using does not support an InputStream, either:
Use that
InputStreamto make a local file copy on your own internal storage, then use that file