Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; public class Main { public static void writeBitmapToDisk(String url, Bitmap bmp, Context ctx, CompressFormat format) { FileOutputStream fos; String fileName = constructFileName(url); try { if (bmp != null) { fos = new FileOutputStream(new File(ctx.getCacheDir(), fileName)); bmp.compress(format, 75, fos); fos.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } public static String constructFileName(String url) { return url.replaceAll("/", "_"); } }