UserDictionaryに単語を追加してそこからクエリを実行できるアプリを開発しています。タブレットデバイスでアプリを実行すると、正常に動作します。しかし、タブレット以外のデバイスで実行し、自動修正された単語を単語リストに保存してクエリを実行すると、単語が取得されませんでした。
だから私はすべての保存された自動修正された単語を照会して選択するために何をすべきか。
// this to add word to dictionary
Uri dic = UserDictionary.Words.CONTENT_URI;
UserDictionary.Words.addWord(this, "word", 100, UserDictionary.Words.LOCALE_TYPE_ALL);
// this to query
Uri dic = UserDictionary.Words.CONTENT_URI;
ContentResolver resolver = getContentResolver();
Cursor cursor = resolver.query(dic, null, null, null, null);
while (cursor.moveToNext()){
String word = cursor.getString(cursor.getColumnIndex(UserDictionary.Words.WORD));
int id = cursor.getInt(cursor.getColumnIndex(UserDictionary.Words._ID));
String app = cursor.getString(cursor.getColumnIndex(UserDictionary.Words.APP_ID));
int frequency = cursor.getInt(cursor.getColumnIndex(UserDictionary.Words.FREQUENCY));
String locale = cursor.getString(cursor.getColumnIndex(UserDictionary.Words.LOCALE));
Log.i("", "word: "+word+"\nId: "+id+"\nAppID: "+app+"\nfrequency: "+frequency+"\nLocale: "+locale);
}