aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-07-21 17:36:57 +0900
committerJean Chalard <jchalard@google.com>2011-07-21 19:14:16 +0900
commite150ef98569d61078e0f8c67ded8364a9c3d4a20 (patch)
tree5ce9e15775f09f98d78cd5745e7c5712c0111ebe /java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
parent728ab86f8c8a94beee1fe1581eb1c51757b84d56 (diff)
downloadlatinime-e150ef98569d61078e0f8c67ded8364a9c3d4a20.tar.gz
latinime-e150ef98569d61078e0f8c67ded8364a9c3d4a20.tar.xz
latinime-e150ef98569d61078e0f8c67ded8364a9c3d4a20.zip
Set the locale for opening an asset
This is necessary because we don't know any more whether the locale of the process is the expected one when the dictionary is loaded asynchronously. Bug: 5023141 Change-Id: Ia9e4741f3b4a04a9f085f5b65ec122471b0c2dff
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java')
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
index 76a230f82..00d80f566 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
@@ -19,6 +19,7 @@ package com.android.inputmethod.latin;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
+import android.content.res.Resources;
import android.net.Uri;
import android.text.TextUtils;
@@ -129,8 +130,11 @@ public class BinaryDictionaryFileDumper {
*/
public static String getDictionaryFileFromResource(int resource, Locale locale,
Context context) throws FileNotFoundException, IOException {
- return copyFileTo(context.getResources().openRawResource(resource),
- getCacheFileNameForLocale(locale, context));
+ final Resources res = context.getResources();
+ final Locale savedLocale = Utils.setSystemLocale(res, locale);
+ final InputStream stream = res.openRawResource(resource);
+ Utils.setSystemLocale(res, savedLocale);
+ return copyFileTo(stream, getCacheFileNameForLocale(locale, context));
}
/**