Reputation: 3053
I have a problem that each time , I take a photo and and I try to display it. Glide load me the old file. I check the file locally , it has been changed successfully. But the old image is displayed.
This is my code :
public void onCameraCaptureCompleted(final File photoFile) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
stopCamera();
pickedImg.setImageBitmap(null);
Glide.with(TakePhotoFragment.this)
.load(photoFile)
.asBitmap()
.dontAnimate()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.into(pickedImg);
}
});
}
Who knows how to solve this problem ?
Upvotes: 6
Views: 2230
Reputation: 65
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
just this worked for me.
Upvotes: 1
Reputation: 75788
Try with skipMemoryCache
Allows the loaded resource to skip the memory cache.
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
NOTE
If same problem still coming then use clearMemory()
.
For good approach, Create Application Class and add this
public class RootApplication extends Application
{
@Override public void onLowMemory() {
super.onLowMemory();
Glide.get(this).clearMemory();
}
Make sure, added this Application class in Manifest
.
<application
android:name=".RootApplication"
>
Upvotes: 11
Reputation: 11018
you may want to clear the cache stored and then restart the application manually
or
just clear the cache from code only. just call clearMemory()
on glide.
Have a look here for more info
Upvotes: 0