Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.graphics.Bitmap; import java.io.File; import java.io.FileOutputStream; public class Main { public static Context sAppContext; public static void saveBitmap(String filename, Bitmap bitmap) throws Exception { File file = new File(sAppContext.getCacheDir().getPath() + "/" + filename); if (file.exists()) { file.delete(); } file.createNewFile(); FileOutputStream fos = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); fos.flush(); fos.close(); } }