转换文件://方案内容://方案 [英] Converting file:// scheme to content:// scheme

查看:124
本文介绍了转换文件://方案内容://方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行的问题,使用的Droid X的文件应用和天文文件管理器来选择一个图像文件。这两个应用程序返回该计划所选择的图像文件://,而画廊返回图像的方案内容://。如何将第一个模式转换到第二。或者,我怎么去code与第二格式的图像?

I am running to the problem with using Droid X's Files app and Astro file manager to select an image file. This two apps return the selected image with the scheme "file://" while Gallery returns the image with the scheme "content://". How do I convert the first schema to the second. Or how do I decode the image with the second format?

推荐答案

您可能要转换的内容://到文件://

You probably want to convert content:// to file://

有关画廊图像,尝试这样的事:

For gallery images, try something like this:

Uri myFileUri;
Cursor cursor = context.getContentResolver().query(uri,new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null);
if(cursor.moveToFirst())
{
    myFileUri = Uri.parse(cursor.getString(0)).getPath();
}
cursor.close

这篇关于转换文件://方案内容://方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆