thest1 / LazyList

Lazy load of images in Android
http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012
MIT License
1.2k stars 497 forks source link

clear() in FileCache.java throws NullPointerException #4

Closed ghost closed 12 years ago

ghost commented 12 years ago

When you do not have permissions setup for external storage and you clear the cache of the application, then reload it and try and clear the cache onload using 'clear()'. It has a null value for 'files' variable and crashes. So I put this null pointer check in here just in case it is ever null again :)

FileCache.java

public void clear(){
    File[] files=cacheDir.listFiles();
    if (files != null)
    {
        for(File f:files)
            f.delete();
    }
}
thest1 commented 12 years ago

Thanks! I've applied your fix.