Here you can find the source of save(Bitmap bitmap, String fileName)
public static String save(Bitmap bitmap, String fileName)
//package com.java2s; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import android.graphics.Bitmap; import android.os.Environment; public class Main { public static final String SDCARD_FOLDER = "eventmanager"; public static String save(Bitmap bitmap, String fileName) { File folder = new File(Environment.getExternalStorageDirectory(), SDCARD_FOLDER);/* w w w . ja va 2s .com*/ if (!folder.exists() && !folder.mkdirs()) { //Log.w(TAG, "Couldn't make dir " + barcodesRoot); //showErrorMessage(R.string.msg_unmount_usb); folder = new File(Environment.getDataDirectory(), SDCARD_FOLDER); } File barcodeFile = new File(folder, fileName + ".png"); barcodeFile.delete(); FileOutputStream fos = null; try { fos = new FileOutputStream(barcodeFile); bitmap.compress(Bitmap.CompressFormat.PNG, 0, fos); return barcodeFile.getAbsolutePath(); } catch (FileNotFoundException fnfe) { //Log.w(TAG, "Couldn't access file " + barcodeFile + " due to " + fnfe); //showErrorMessage(R.string.msg_unmount_usb); return ""; } finally { if (fos != null) { try { fos.close(); } catch (IOException ioe) { // do nothing } } } } }