Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get Uri of image file from its name?

Tags:

android

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?

like image 350
skysign Avatar asked Feb 01 '10 04:02

skysign


1 Answers

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();

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

Uri uri = Uri.fromFile(file);
like image 89
Erich Douglass Avatar answered Oct 12 '22 02:10

Erich Douglass