6

I have found that on my device, the default media display tool is not showing me the same if Ihave a uri that is:

file://mnt/sdcard/DCIM/Image.jpg

When I go through picking the image with the built in intent I get this:

content://media/external/images/media/247 

These both display the same file, but I don't have any sharing options when I use the first one.

My question is, how can I find the content Uri given the file Uri?

rds
  • 26,253
  • 19
  • 107
  • 134
weston
  • 54,145
  • 21
  • 145
  • 203

1 Answers1

11

I was making the file, so I had a File object file.

So I do this now to get Uri for the file as a "content://" Uri.

Uri capturedImage = Uri.parse(
      android.provider.MediaStore.Images.Media.insertImage(
      getContentResolver(),
      file.getAbsolutePath(), null, null));

Credit to answer on this question How can I capture an image in Android and have it show up in the gallery?

Community
  • 1
  • 1
weston
  • 54,145
  • 21
  • 145
  • 203
  • @tejshah It's customary to click the grey up arrow to show appreciation for a useful answer :) – weston Oct 03 '17 at 18:55