From 59399506dfdddb01996a07165218634c00e12993 Mon Sep 17 00:00:00 2001 From: Marcus Wolschon Date: Tue, 19 Apr 2011 09:01:01 +0200 Subject: [PATCH] fixed very rare NullPointerException --- src/com/fsck/k9/provider/AttachmentProvider.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/provider/AttachmentProvider.java b/src/com/fsck/k9/provider/AttachmentProvider.java index 126223d72..8b234113b 100644 --- a/src/com/fsck/k9/provider/AttachmentProvider.java +++ b/src/com/fsck/k9/provider/AttachmentProvider.java @@ -72,7 +72,14 @@ public class AttachmentProvider extends ContentProvider { * We use the cache dir as a temporary directory (since Android doesn't give us one) so * on startup we'll clean up any .tmp files from the last run. */ - File[] files = getContext().getCacheDir().listFiles(); + final File cacheDir = getContext().getCacheDir(); + if (cacheDir == null) { + return true; + } + File[] files = cacheDir.listFiles(); + if (files == null) { + return true; + } for (File file : files) { if (file.getName().endsWith(".tmp")) { file.delete();