defaultDic.setEntries(entries);
defaultDic.setEntryValues(entryvalues);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ prefs.unregisterOnSharedPreferenceChangeListener(this);
+ }
+ @Override
+ protected void onResume() {
+ super.onResume();
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
}
public void onSharedPreferenceChanged(SharedPreferences p, String v) {
final DictionaryApplication application = (DictionaryApplication)getApplication();
File dictDir = application.getDictDir();
- if (!dictDir.isDirectory() || !dictDir.canWrite()) {
+ if (!dictDir.isDirectory() || !dictDir.canWrite() ||
+ !application.checkFileCreate(dictDir)) {
String dirs = "";
String externalDir = Environment.getExternalStorageDirectory().getAbsolutePath();
if (new File(externalDir).canWrite())
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("Chosen directory not writeable, try one of" + dirs)
+ .setMessage(getString(R.string.chosenNotWritable) + dirs)
.setNeutralButton("Close", null).show();
}
}