2012-02-05 69 views
7

我发现我的设备上,默认的媒体显示工具不显示我相同的,如果IHAVE一个URI是:如何将一个文件:// uri转换成content:// uri?

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

当我去通过与采摘图像内置的意图,我得到这个:

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

这些都显示相同的文件,但我没有任何共享选项,当我使用第一个。

我的问题是,如何找到Uri给出文件Uri的内容?

+0

我有相反的问题 - 我从insertImage内容URI,我需要一个文件的URL。 – Richard 2013-01-25 20:37:44

+1

@理查德问这是一个新问题,否则你只会引起我的注意。 – weston 2013-01-27 16:55:07

+0

谢谢;通过进一步的搜索找到它。 – Richard 2013-01-28 00:10:55

回答

11

我正在制作文件,所以我有一个File对象file

因此,我现在要做的就是将Uri作为“content://”Uri获取。

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

信用来回答这个问题How can I capture an image in Android and have it show up in the gallery?

+0

工作长官。 thatnkx – 2017-10-03 13:29:53

+0

@tejshah习惯上点击灰色的向上箭头表示赞赏有用的答案:) – weston 2017-10-03 18:55:24