Imene Noomene
Imene Noomene

Reputation: 3053

Glide loads the old image

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

Answers (3)

user3509903
user3509903

Reputation: 65

.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)

just this worked for me.

Upvotes: 1

IntelliJ Amiya
IntelliJ Amiya

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

vikas kumar
vikas kumar

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

Docs

Upvotes: 0

Related Questions