+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences p, String v) {
+ DictionaryApplication.INSTANCE.init(getApplicationContext());
+ final DictionaryApplication application = DictionaryApplication.INSTANCE;
+ File dictDir = application.getDictDir();
+ if (!dictDir.isDirectory() || !dictDir.canWrite() ||
+ !DictionaryApplication.checkFileCreate(dictDir)) {
+ String dirs = "";
+ String externalDir = Environment.getExternalStorageDirectory().getAbsolutePath();
+ if (new File(externalDir).canWrite())
+ dirs += "\n" + externalDir + "/quickDic";
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ File[] files = getApplicationContext().getExternalFilesDirs(null);
+ for (File f : files) {
+ if (f.canWrite())
+ dirs += "\n" + f.getAbsolutePath();
+ }
+ } else {
+ 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();
+ }
+ }