return dictDir;
}
+ static public boolean checkFileCreate(File dir) {
+ boolean res = false;
+ File testfile = new File(dir, "quickdic_writetest");
+ try {
+ testfile.delete();
+ res = testfile.createNewFile() & testfile.delete();
+ } catch (Exception e) {
+ }
+ return res;
+ }
+
public File getWordListFile() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String file = prefs.getString(getString(R.string.wordListFileKey), "");
Toast.LENGTH_LONG).show();
} catch (Exception e) {
String msg = getString(R.string.unzippingFailed, dest);
- if (!application.getDictDir().canWrite()) {
- msg = getString(R.string.notWritable, application.getDictDir().getAbsolutePath());
+ File dir = application.getDictDir();
+ if (!dir.canWrite() || !application.checkFileCreate(dir)) {
+ msg = getString(R.string.notWritable, dir.getAbsolutePath());
}
new AlertDialog.Builder(context).setTitle(getString(R.string.error)).setMessage(msg).setNeutralButton("Close", null).show();
Log.e(LOG, "Failed to unzip.", e);
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())