Search code examples
androidandroid-recyclerviewpicasso

How to delete all files from Android Picasso cache


I am working on a project where iam using picasso (http://square.github.io/picasso/) to load all the images in a Recycler View, i wanted to remove all the files from the Picasso cache at the time of logging out of the application. Can you please help me how to do that, i dont want to invalidate every single file separately, also where does it save all the files?


Solution

  • I myself was searching on how to clear the whole cache few days back and stumbled upon it on Stackoverflow itself, cannot seem to find the thread now but here's my code.

    Add this class to the com.squareup.picasso package :

     package com.squareup.picasso;
    
        public class PicassoTools {
    
            public static void clearCache (Picasso picasso) {
                picasso.cache.clear();
            }
        }
    

    And simply call this on logout method :

    PicassoTools.clearCache(Picasso.with(context));