Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.graphics.Bitmap; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; public class Main { /** * Write image to internal storage * @param context : Context android. * @param fileName : Image file name. * @param image : Bitmap image format PNG only. */ public static void saveImageToInternalStorage(Context context, String fileName, Bitmap image) { // Convert Bitmap to byteArray ByteArrayOutputStream stream = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteArray = stream.toByteArray(); // Open fileOutput with fileName and write byteArray try { FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE); if (fos != null) { fos.write(byteArray); fos.close(); } } catch (Exception e) { e.printStackTrace(); } } }