Code example for SoftReference

Methods: clear, get

0
	public void clearMemory(String key, boolean recycle) {
		if (cache.containsKey(key) && cache.get(key).get() != null) {
			SoftReference<Bitmap> sr = cache.get(key);
			cache.remove(sr);
			if (recycle) {
				sr.get().recycle();
			} 
			sr.clear();
			sr = null;
		} 
	} 
 
	public void copyStream(InputStream is, OutputStream os) {
		final int buffer_size = 1024;
		try { 
			byte[] bytes = new byte[buffer_size];
			for (;;) { 
				int count = is.read(bytes, 0, buffer_size);
				if (count == -1)
					break; 
				os.write(bytes, 0, count);