How to convert the file: // uri to content: // uri?

I found that on my device, the default environment mapping tool does not show me the same if I have a uri that:

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

When I view an image with an embedded intent, I get the following:

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

Both of them display the same file, but I have no sharing options when I use the first one.

My question is, how can I find the contents of a Uri given a Uri file?

+7
source share
1 answer

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

So, I am doing this now to get the Uri for the file as "content: //" Uri.

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

Credit for answering this question. How can I capture an image in Android and show it in the gallery?

+11
source

All Articles