Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; 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(CompressFormat.JPEG, quality, stream); byte[] bytes = stream.toByteArray(); fos.write(bytes); fos.close(); } }