]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Work around Android crash bug in getExternalFilesDir.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sun, 13 Mar 2016 15:46:10 +0000 (16:46 +0100)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sun, 13 Mar 2016 15:46:10 +0000 (16:46 +0100)
This seems to happen in some cases when there is no
SD card.

src/com/hughes/android/dictionary/DictionaryApplication.java
src/com/hughes/android/dictionary/PreferenceActivity.java

index 3c351d9da35eb12fa31a999cca6d78aec931a6f8..99e3088c0c18acdcdfe88bb299adf9584df6d0f5 100644 (file)
@@ -409,7 +409,11 @@ public class DictionaryApplication extends Application {
         if (dictDir.isDirectory() && dictDir.list().length > 0) {
             return dir;
         }
-        File efd = getApplicationContext().getExternalFilesDir(null);
+        File efd = null;
+        try {
+            efd = getApplicationContext().getExternalFilesDir(null);
+        } catch (Exception e) {
+        }
         if (efd != null) {
             efd.mkdirs();
             if (!dictDir.isDirectory() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
index 2d66bf945235b48375e5730005a689c89906a5fb..4481f46a737db3a568132bb828be286ed7e9591b 100644 (file)
@@ -104,7 +104,11 @@ public class PreferenceActivity extends android.preference.PreferenceActivity
                         dirs += "\n" + f.getAbsolutePath();
                 }
             } else {
-                File efd = getApplicationContext().getExternalFilesDir(null);
+                File efd = null;
+                try {
+                    efd = getApplicationContext().getExternalFilesDir(null);
+                } catch (Exception e) {
+                }
                 if (efd != null) {
                     String externalFilesDir = efd.getAbsolutePath();
                     if (new File(externalFilesDir).canWrite())