0
我想在我的asyncTask中測試這個緩存。我將如何去做這件事?如何測試緩存中的文件?
public void putBitmapInDiskCache(URI imageUri, Bitmap avatar) {
File cacheDir = new File(this.getCacheDir(), "thumbnails");
cacheDir.mkdirs();
File cacheFile = new File(cacheDir, ""+imageUri.hashCode());
try {
cacheFile.createNewFile();
FileOutputStream fos = new FileOutputStream(cacheFile);
avatar.compress(CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
} catch (Exception e) {
Log.e("error", "Error when saving image to cache. ", e);
}