壁画以编程方式将位图添加到caching

我上传一个图像到我的服务器,一旦上传我的服务器响应与新的URI(可以是旧的相同的URL),我想删除旧的caching的图像,并插入新的URI为新的URI。

我试图做到这一点:

// Retrofit2 onResponse String newImageUri = response.body().getUri(); String oldImageUri = Preferences.getUser().getImageUrl(); // Remove old image from cache Fresco.getImagePipeline().evictFromCache(Uri.parse(oldImageUri)); Fresco.getImagePipeline().evictFromDiskCache(Uri.parse(oldImageUri)); Fresco.getImagePipeline().evictFromMemoryCache(Uri.parse(oldImageUri)); Fresco.getImagePipelineFactory().getMainFileCache().remove(new SimpleCacheKey(oldImageUri)); // Insert new image at new URI try { Fresco.getImagePipelineFactory().getMainFileCache().insert(new SimpleCacheKey(newImageUri), new WriterCallback() { @Override public void write(OutputStream os) throws IOException { os.write(imageData); // byte[] or the new Bitmap } }); } catch (Exception e) { e.printStackTrace(); } uriProfileImage.setImageURI(newImageUri); 

没有例外,但我仍然只看到旧的形象。

Solutions Collecting From Web of "壁画以编程方式将位图添加到caching"