I want to save an image from a URL to the SD card (for future use) and then load that image from the SD card to use it as a drawable overlay for Google maps.
Here is the save section of the function:
//SAVE TO FILE
String filepath = Environment.getExternalStorageDirectory().getAbsolutePath();
String extraPath = "/Map-"+RowNumber+"-"+ColNumber+".png";
filepath += extraPath;
FileOutputStream fos = null;
fos = new FileOutputStream(filepath);
bmImg.compress(CompressFormat.PNG, 75, fos);
//LOAD IMAGE FROM FILE
Drawable d = Drawable.createFromPath(filepath);
return d;
The image is saved to the sd card succuessfully but fails when getting to the createFromPath()
line. I don't understand why it would save ok to that destination but not load from it....
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…