From: Reimar Döffinger Date: Mon, 14 Mar 2016 20:33:28 +0000 (+0100) Subject: Small improvements when SDcard is missing. X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=04322d74c5e80b77dc82adbc0c47fb75269694ce Small improvements when SDcard is missing. Unfortunately, downloads are impossible if there is no "external" directory. --- diff --git a/src/com/hughes/android/dictionary/DictionaryApplication.java b/src/com/hughes/android/dictionary/DictionaryApplication.java index 99e3088..50acb43 100644 --- a/src/com/hughes/android/dictionary/DictionaryApplication.java +++ b/src/com/hughes/android/dictionary/DictionaryApplication.java @@ -423,6 +423,9 @@ public class DictionaryApplication extends Application { return efd.getAbsolutePath(); } } + if (!dictDir.isDirectory() && !dictDir.mkdirs()) { + return getApplicationContext().getFilesDir().getAbsolutePath(); + } return dir; } diff --git a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java index 28a3635..e0b2574 100644 --- a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java @@ -666,7 +666,7 @@ public class DictionaryManagerActivity extends ActionBarActivity { try { request.setDestinationInExternalFilesDir(getApplicationContext(), null, destFile); - } catch (IllegalStateException e) { + } catch (Exception e) { request.setDestinationUri(Uri.fromFile(new File(Environment .getExternalStorageDirectory(), destFile))); } diff --git a/src/com/hughes/android/dictionary/PreferenceActivity.java b/src/com/hughes/android/dictionary/PreferenceActivity.java index 4481f46..bcca16a 100644 --- a/src/com/hughes/android/dictionary/PreferenceActivity.java +++ b/src/com/hughes/android/dictionary/PreferenceActivity.java @@ -115,6 +115,9 @@ public class PreferenceActivity extends android.preference.PreferenceActivity 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();