この問題をウェブ全体で検索して調べましたが、明確な答えが得られませんでした。Androidのドキュメントには単語が追加されると記載されているため、コンテンツ プロバイダーを使用してユーザー辞書に単語を追加しましたが、その後キーパッドに入力すると、候補ビューの候補に単語が表示されず、タップした他の単語として表示されません。次回そこに登場。多くの人がネット上で質問し、回答を得られていないため、この問題に対する完全な回答を本当に感謝しています. 私はこれを試しました
Uri mNewUri;
// Defines an object to contain the new values to insert
ContentValues mNewValues = new ContentValues();
// Sets the values of each column and inserts the word. The arguments to the "put"
// method are "column name" and "value"
mNewValues.put(UserDictionary.Words.APP_ID, "example.user");
mNewValues.put(UserDictionary.Words.LOCALE, "en_US");
mNewValues.put(UserDictionary.Words.WORD, "Qasim");
mNewValues.put(UserDictionary.Words.FREQUENCY, "100");
mNewUri = getContentResolver().insert(
UserDictionary.Words.CONTENT_URI, // the user dictionary content URI
mNewValues // the values to insert
);
Uri dic = UserDictionary.Words.CONTENT_URI;
ContentResolver resolver = getContentResolver();
Cursor cursor = resolver.query(dic, null, null, null, null);
//here i retrieve all the words stored into my dictionary
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);
}
誰かがここで私を助けてくれれば幸いです