diff options
author | 2011-08-10 16:37:46 +0900 | |
---|---|---|
committer | 2011-08-10 17:14:34 +0900 | |
commit | d4c08d9be3540466c8253ee02fecf4b6035d8ee0 (patch) | |
tree | 65de26337c9d3598ea7b404bdd2a5bac024aa365 /java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java | |
parent | cfca3c6317143ce68770cab02eb7d7a5dc8765c9 (diff) | |
download | latinime-d4c08d9be3540466c8253ee02fecf4b6035d8ee0.tar.gz latinime-d4c08d9be3540466c8253ee02fecf4b6035d8ee0.tar.xz latinime-d4c08d9be3540466c8253ee02fecf4b6035d8ee0.zip |
Make sure the directory where to put files actually exists
Bug: 5095140
Change-Id: I764471e54ce0bf6aefe5d604cee97639d5ad0af9
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java index b8850680b..2d50a6f46 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java @@ -23,6 +23,7 @@ import android.content.res.Resources; import android.database.Cursor; import android.net.Uri; import android.text.TextUtils; +import android.util.Log; import java.io.File; import java.io.FileInputStream; @@ -40,6 +41,8 @@ import java.util.Locale; * file from the dictionary provider */ public class BinaryDictionaryFileDumper { + private static final String TAG = BinaryDictionaryFileDumper.class.getSimpleName(); + /** * The size of the temporary buffer to copy files. */ @@ -79,8 +82,16 @@ public class BinaryDictionaryFileDumper { * Find out the cache directory associated with a specific locale. */ private static String getCacheDirectoryForLocale(Locale locale, Context context) { - final String directoryName = replaceFileNameDangerousCharacters(locale.toString()); - return context.getFilesDir() + File.separator + directoryName; + final String relativeDirectoryName = replaceFileNameDangerousCharacters(locale.toString()); + final String absoluteDirectoryName = context.getFilesDir() + File.separator + + relativeDirectoryName; + final File directory = new File(absoluteDirectoryName); + if (!directory.exists()) { + if (!directory.mkdirs()) { + Log.e(TAG, "Could not create the directory for locale" + locale); + } + } + return absoluteDirectoryName; } /** |