From 9ec94e8e8827b82e45e2bc468e68c8c1bdf32e75 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Fri, 7 Jun 2013 11:59:05 +0100 Subject: [PATCH] Don't get upset if the SD card is not ready yet --- src/org/fdroid/fdroid/FDroidApp.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/org/fdroid/fdroid/FDroidApp.java b/src/org/fdroid/fdroid/FDroidApp.java index 2690a2a4c..5c1fb98b9 100644 --- a/src/org/fdroid/fdroid/FDroidApp.java +++ b/src/org/fdroid/fdroid/FDroidApp.java @@ -47,9 +47,14 @@ public class FDroidApp extends Application { SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(getBaseContext()); if(!prefs.getBoolean("cacheDownloaded", false)) { - for(File f : local_path.listFiles()) { - if(f.getName().endsWith(".apk")) { - f.delete(); + File[] files = local_path.listFiles(); + // files can be null if the SD card is not ready - we'll just + // ignore that and do it next time. + if(files != null) { + for(File f : files) { + if(f.getName().endsWith(".apk")) { + f.delete(); + } } } }