我正在开发一个可以向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);
}