安卓得到真正的路径由Uri.getPath() [英] android get real path by Uri.getPath()

查看:3087
本文介绍了安卓得到真正的路径由Uri.getPath()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从库获取的图像。

I'm trying to get image from gallery.

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select picture"), resultCode );

在我从这次活动我有一个数据,其中包含乌里返回。它看起来像:

After I returned from this activity I have a data, which contains Uri. It looks like:

content://media/external/images/1

我怎么能这样的路径转换为真实的(就像' /sdcard/image.png ')?

感谢

推荐答案

难道真的有必要让你获得一个物理路径?
例如, ImageView.setImageUri() ContentResolver.openInputStream()允许您访问文件的内容而不知道它的真实路径。

Is it really necessary for you to get a physical path?
For example, ImageView.setImageUri() and ContentResolver.openInputStream() allow you to access the contents of a file without knowing its real path.

这篇关于安卓得到真正的路径由Uri.getPath()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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