aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/UserDictionary.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2010-12-16 12:19:09 +0900
committerTadashi G. Takaoka <takaoka@google.com>2010-12-16 12:25:01 +0900
commit1d11e7903fa7ed4665d6ffba6b23c51ccc679872 (patch)
tree03c5f4715d13e9e5364730b18f19cc59074ca12d /java/src/com/android/inputmethod/latin/UserDictionary.java
parent68b69320242206e4ec9e0bae78282077c74dfed2 (diff)
downloadlatinime-1d11e7903fa7ed4665d6ffba6b23c51ccc679872.tar.gz
latinime-1d11e7903fa7ed4665d6ffba6b23c51ccc679872.tar.xz
latinime-1d11e7903fa7ed4665d6ffba6b23c51ccc679872.zip
Fix adding user dictionary
This change is follow up of I9fe45a61 Bug: 3264920 Change-Id: Ic7b95892e36e30fd9fadd7bea011efad7f2f98ca
Diffstat (limited to 'java/src/com/android/inputmethod/latin/UserDictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/UserDictionary.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/java/src/com/android/inputmethod/latin/UserDictionary.java b/java/src/com/android/inputmethod/latin/UserDictionary.java
index e03f56498..56ee5b9e7 100644
--- a/java/src/com/android/inputmethod/latin/UserDictionary.java
+++ b/java/src/com/android/inputmethod/latin/UserDictionary.java
@@ -26,14 +26,16 @@ import android.provider.UserDictionary.Words;
public class UserDictionary extends ExpandableDictionary {
- private static final String[] PROJECTION = {
- Words._ID,
+ private static final String[] PROJECTION_QUERY = {
Words.WORD,
- Words.FREQUENCY
+ Words.FREQUENCY,
};
- private static final int INDEX_WORD = 1;
- private static final int INDEX_FREQUENCY = 2;
+ private static final String[] PROJECTION_ADD = {
+ Words._ID,
+ Words.FREQUENCY,
+ Words.LOCALE,
+ };
private ContentObserver mObserver;
private String mLocale;
@@ -67,7 +69,7 @@ public class UserDictionary extends ExpandableDictionary {
@Override
public void loadDictionaryAsync() {
Cursor cursor = getContext().getContentResolver()
- .query(Words.CONTENT_URI, PROJECTION, "(locale IS NULL) or (locale=?)",
+ .query(Words.CONTENT_URI, PROJECTION_QUERY, "(locale IS NULL) or (locale=?)",
new String[] { mLocale }, null);
addWords(cursor);
}
@@ -100,7 +102,7 @@ public class UserDictionary extends ExpandableDictionary {
new Thread("addWord") {
@Override
public void run() {
- Cursor cursor = contentResolver.query(Words.CONTENT_URI, PROJECTION,
+ Cursor cursor = contentResolver.query(Words.CONTENT_URI, PROJECTION_ADD,
"word=? and ((locale IS NULL) or (locale=?))",
new String[] { word, mLocale }, null);
if (cursor != null && cursor.moveToFirst()) {
@@ -139,9 +141,11 @@ public class UserDictionary extends ExpandableDictionary {
final int maxWordLength = getMaxWordLength();
if (cursor.moveToFirst()) {
+ final int indexWord = cursor.getColumnIndex(Words.WORD);
+ final int indexFrequency = cursor.getColumnIndex(Words.FREQUENCY);
while (!cursor.isAfterLast()) {
- String word = cursor.getString(INDEX_WORD);
- int frequency = cursor.getInt(INDEX_FREQUENCY);
+ String word = cursor.getString(indexWord);
+ int frequency = cursor.getInt(indexFrequency);
// Safeguard against adding really long words. Stack may overflow due
// to recursion
if (word.length() < maxWordLength) {