Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void saveImage(Context context, String fileName, Bitmap bitmap) throws IOException { saveImage(context, fileName, bitmap, 100); } public static void saveImage(Context context, String fileName, Bitmap bitmap, int quality) throws IOException { if (bitmap == null || fileName == null || context == null) return; FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream); byte[] bytes = stream.toByteArray(); fos.write(bytes); fos.close(); } }