Clear Glide Image Cache in Android

Viewed 5912

I am using glide library for showing images. I am trying to clear glide cache by using the following code:

Glide.get(MainActivity.this).clearDiskCache();
Glide.get(MainActivity.this).clearMemory();

the above code is inside Async and I call in Do background part.

When I run this I am always getting:

Caused by: java.lang.IllegalArgumentException: You must call this method on the main thread
at com.bumptech.glide.util.Util.assertMainThread(Util.java:135)
at com.bumptech.glide.Glide.clearMemory(Glide.java:370)

What could be wrong here? If I use the above in MainThread it is asking to run it in background.

How do I clear cache?

Thanks!

1 Answers
Related