Java tutorial
//package com.java2s; import android.graphics.Bitmap; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { @SuppressWarnings("ResultOfMethodCallIgnored") public static boolean saveBitmap(Bitmap bitmap, String filePath, int quality) { boolean result = false; FileOutputStream fileOutputStream = null; try { File file = new File(filePath); if (file.exists()) file.delete(); fileOutputStream = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.JPEG, quality, fileOutputStream); fileOutputStream.flush(); result = true; } catch (IOException ignored) { } finally { if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException ignored) { } } } return result; } }