]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/PreferenceActivity.java
Attempt to fix issue #49.
[Dictionary.git] / src / com / hughes / android / dictionary / PreferenceActivity.java
index a415d871a262839ce6ecdff1f6462b6b4c3fb81e..1e7ba15c54cf3fee16df1b32d8fc8c908f656e3a 100644 (file)
@@ -35,7 +35,7 @@ public class PreferenceActivity extends android.preference.PreferenceActivity
     public void onCreate(Bundle savedInstanceState) {
         final DictionaryApplication application = (DictionaryApplication) getApplication();
         setTheme(application.getSelectedTheme().themeId);
-        
+
         final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
         if (prefs.getString(getString(R.string.quickdicDirectoryKey), "").equals("")) {
             prefs.edit().putString(getString(R.string.quickdicDirectoryKey), application.getDictDir().getAbsolutePath()).commit();
@@ -104,10 +104,20 @@ public class PreferenceActivity extends android.preference.PreferenceActivity
                         dirs += "\n" + f.getAbsolutePath();
                 }
             } else {
-                String externalFilesDir = getApplicationContext().getExternalFilesDir(null).getAbsolutePath();
-                if (new File(externalFilesDir).canWrite())
-                    dirs += "\n" + externalFilesDir;
+                File efd = null;
+                try {
+                    efd = getApplicationContext().getExternalFilesDir(null);
+                } catch (Exception e) {
+                }
+                if (efd != null) {
+                    String externalFilesDir = efd.getAbsolutePath();
+                    if (new File(externalFilesDir).canWrite())
+                        dirs += "\n" + externalFilesDir;
+                }
             }
+            File fd = getApplicationContext().getFilesDir();
+            if (fd.canWrite())
+                dirs += "\n" + fd.getAbsolutePath();
             new AlertDialog.Builder(this).setTitle(getString(R.string.error))
                 .setMessage(getString(R.string.chosenNotWritable) + dirs)
                     .setNeutralButton("Close", null).show();