vijay
12/8/2014 - 3:47 PM

saving a bitmap image to Cache Memroy

saving a bitmap image to Cache Memroy

// this method is save a bitmap image to cache memory
	public void saveToCache(Bitmap image) {

		try {

			FileOutputStream output = new FileOutputStream(new File(
					getCacheDir(), "maacarevk"));
			image.compress(Bitmap.CompressFormat.PNG, 100, output);

			try {
				output.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

		Log.d("6mhkrh", "Method called");

	}
// i get file name maacarevk from cache directory
				File file = new File(getCacheDir(), "maacarevk");
				
// now i convert file to bitmap
				Bitmap imageFromCache = BitmapFactory.decodeFile(file.getAbsolutePath());