diff options
| author | Tom Ouyang <ouyang@google.com> | 2012-04-24 09:59:11 -0700 |
|---|---|---|
| committer | Tom Ouyang <ouyang@google.com> | 2012-04-24 10:52:53 -0700 |
| commit | a9b2be8a8140d78a468b2a7b839b50e555a4312b (patch) | |
| tree | 05932832db7691a42abaf3e4beb90ad4c93c24bf /java | |
| parent | 7f45ec7bb88e36fa7e430d18e852937132b68ea6 (diff) | |
| download | android_packages_inputmethods_LatinIME-a9b2be8a8140d78a468b2a7b839b50e555a4312b.tar.gz android_packages_inputmethods_LatinIME-a9b2be8a8140d78a468b2a7b839b50e555a4312b.tar.bz2 android_packages_inputmethods_LatinIME-a9b2be8a8140d78a468b2a7b839b50e555a4312b.zip | |
Change expandable binary dict write to a temp file first.
Bug: 6380724
Change-Id: Ic1d0d902dc45ecb41a1792f33a60ab85e606fcef
Diffstat (limited to 'java')
| -rw-r--r-- | java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index 7d2ccdf5f..9dcffd4e2 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -288,13 +288,16 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { loadDictionaryAsync(); + final String tempFileName = mFilename + ".temp"; final File file = new File(mContext.getFilesDir(), mFilename); + final File tempFile = new File(mContext.getFilesDir(), tempFileName); FileOutputStream out = null; try { - out = new FileOutputStream(file); + out = new FileOutputStream(tempFile); BinaryDictInputOutput.writeDictionaryBinary(out, mFusionDictionary, 1); out.flush(); out.close(); + tempFile.renameTo(file); clearFusionDictionary(); } catch (IOException e) { Log.e(TAG, "IO exception while writing file: " + e); |
