Code example for FileLruCache

    private volatile static FileLruCache imageCache;
    synchronized static FileLruCache getCache(Context context) throws IOException{
        if (imageCache == null) {
            imageCache = new FileLruCache(context.getApplicationContext(), TAG, new FileLruCache.Limits());
        return imageCache;
    // Get stream from cache, or return null if the image is not cached. 
    // Does not throw if there was an error. 
    static InputStream getCachedImageStream(URL url, Context context) {
        InputStream imageStream = null;
        if (url != null) {
            if (isCDNURL(url)) {
                try { 
                    FileLruCache cache = getCache(context);
                    imageStream = cache.get(url.toString());
                } catch (IOException e) {
Experience pair programming with AI  Get Codota for Java