diff --git a/collect_app/src/main/java/org/odk/collect/android/provider/InstanceProvider.java b/collect_app/src/main/java/org/odk/collect/android/provider/InstanceProvider.java index a04b1e2bde8..3cd7a9dbb18 100644 --- a/collect_app/src/main/java/org/odk/collect/android/provider/InstanceProvider.java +++ b/collect_app/src/main/java/org/odk/collect/android/provider/InstanceProvider.java @@ -224,10 +224,12 @@ private void deleteAllFilesInDirectory(File directory) { // delete all the files in the directory File[] files = directory.listFiles(); - for (File f : files) { - // should make this recursive if we get worried about - // the media directory containing directories - f.delete(); + if (files != null) { + for (File f : files) { + // should make this recursive if we get worried about + // the media directory containing directories + f.delete(); + } } } directory.delete();