我可以得到的图像文件的开放的我们从它的名字? [英] Can I get Uri of image file from its name?

查看:119
本文介绍了我可以得到的图像文件的开放的我们从它的名字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些图像文件,我想这些图像文件的URI。 在我的code,我只知道映像文件的路径和文件名。 我怎样才能从它的路径和文件名获得乌里?

There are some image files, and I want to get Uri of these image files. In my code, I only know path and file name of image files. How can I get Uri from its path and file name?

推荐答案

如果你有一个文件,你可以随时将其转换为 URI

If you have a File, you can always convert it to a URI:

File file = new File(path + File.pathSeparator + filename);
URI uri = file.toURI();

或者,如果你想使用Android Uri类:

Or, if you want to use the Android Uri class:

Uri uri = Uri.fromFile(file);

这篇关于我可以得到的图像文件的开放的我们从它的名字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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