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?
+2
A:
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);
Erich Douglass
2010-02-01 04:57:40
Thanks you. Actually, I'm looking for Uri not URI, but they are almost same, so I can find solution.
skysign
2010-02-01 07:32:02
Ah, I didn't know you meant the Android specific Uri class. I've updated my answer to include that as well.
Erich Douglass
2010-02-01 15:03:33
Thank you for update of reply.
skysign
2010-02-02 08:53:29