4

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
  • 1
    You 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. Commented Jun 16, 2016 at 21:23

1 Answer 1

3

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 BLOB in 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:

  • Switch to a better API, or

  • Use that InputStream to make a local file copy on your own internal storage, then use that file

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.