Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; public class Main { public static Bitmap getBitmapFromDisk(String url, Context ctx) { Bitmap defautBitmap = null; try { String filename = constructFileName(url); File filePath = new File(ctx.getCacheDir(), filename); if (filePath.exists() && filePath.isFile() && !filePath.isDirectory()) { FileInputStream fi; BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inPreferredConfig = Config.RGB_565; fi = new FileInputStream(filePath); defautBitmap = BitmapFactory.decodeStream(fi, null, opts); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (Exception e) { } catch (OutOfMemoryError e) { } return defautBitmap; } public static String constructFileName(String url) { return url.replaceAll("/", "_"); } }