public static void saveMyBitmap(String dirName,String bitName, Activity act)
throws IOException {
String foldername = Environment.getExternalStorageDirectory().getPath()
+ "/"+dirName;
File folder = new File(foldername);
if (folder == null || !folder.exists()) {
folder.mkdir();
}
String fileName = "/" +bitName+ ".png";
File targetFile = new File(foldername + fileName);
if (!targetFile.exists()) {
targetFile.createNewFile();
}
FileOutputStream fOut = null;
try {
fOut = new FileOutputStream(targetFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeResource(act.getResources(),
R.drawable.icon);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
try {
fOut.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}