Reputation: 178
In my application, I have a file:
private File TEMP_PHOTO_FILE = new File(Environment.getExternalStorageDirectory(), "temp_photo.jpg");
This is declared directly in my class, and is visible to all the methods there in.
I want to use this:
Bitmap thePhoto = BitmapFactory.decodeFile(Uri.fromFile(TEMP_PHOTO_FILE).toString());
Uri.fromFile(TEMP_PHOTO_FILE).toString() generates the string: "file:///mnt/sdcard/temp_photo.jpg"
Why does this not work? It seems that since we're dealing with a file, there should be some method of decodeFile() that accepts a URI as input. Not allowing that is very frustrating due to the inconsistency.
Upvotes: 5
Views: 9224
Reputation: 13242
"file://" doesn't work. Try this:
Bitmap thePhoto = BitmapFactory.decodeFile(TEMP_PHOTO_FILE.getAbsolutePath().toString());
Upvotes: 3