Try the following:
File folder = context.getDir("images", Context.MODE_WORLD_WRITEABLE); File img = new File(folder, "img_"+widget_id+"_"+position+".png"); try{ FileOutputStream out = new FileOutputStream(img); b.compress(Bitmap.CompressFormat.PNG, 100, out); b.recycle(); internal_img = img.getPath(); }catch(Exception e){ e.printStackTrace(); }
getDir create a folder in the internal memory that you can write, whatever you want inside, do not prevent deletion on the SD card. Also, if the SD card is disconnected, you cannot read / write your files.
source share