I’ve got a situation where I know the path of a file, and address it this way:
File f = new File(Environment.getExternalStorageDirectory(), "image.jpg");
And then create a Uri from it:
Uri uri = Uri.fromFile(f);
However, this Uri prints out something like:
file://.....
But I want:
content://.....
“Why?”. Because some apps are scheme sensitive, like Facebook. If you pass a file-scheme Uri to Facebook when attaching an image, it does nothing. If you pass a content-scheme Uri to the same image, it works perfectly.
So how can I get the content Uri, either by knowing the absolute path, or converting the file-scheme Uri to a content-scheme Uri?
Edit (24th of August 2012): The latest Facebook app update “solved” this by simply removing the picker, and just showing the gallery. You can no longer pick via an intent at all in Facebook.
So far my best bet seems to be this approach of scanning the file, which then returns a Uri with the content-scheme: