3

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);
         }
4

1 に答える 1

2

単語を追加するには、JavadocはUserDicrionary.Words.addWordの使用を提案します。

スペルチェーカーを使用するために、Android 4.0より上に、フレームワークとその使用例がいくつかあります。これらの助けを願っています。

于 2012-10-04T17:21:37.380 に答える