我似乎找不到任何好的示例代码来说明如何在给定单词的情况下查询UserDictionary内容提供商。我的查询如下所示:
Cursor cur = getContentResolver().query(
UserDictionary.Words.CONTENT_URI,
new String[] {Words._ID, Words.WORD},
Words.WORD + "=?",
new String[] {"test"},
null);我也尝试过不指定查询,也不指定投影,并且游标始终为空。我已将android.permission.READ_USER_DICTIONARY包含在我的清单中。
发布于 2012-01-13 20:51:34
尝尝这个
final String[] QUERY_PROJECTION = {
UserDictionary.Words._ID,
UserDictionary.Words.WORD
};
Cursor cursor = getContentResolver()
.query(UserDictionary.Words.CONTENT_URI, QUERY_PROJECTION, "(locale IS NULL) or (locale=?)",
new String[] { Locale.getDefault().toString() }, null);我没有测试过这个,只是一个建议。
发布于 2016-06-18 05:24:41
从API23开始,用户字典只能通过输入法和拼写检查器访问。https://developer.android.com/reference/android/provider/UserDictionary.html
android.permission.READ_USER_DICTIONARY权限在M中不再可用
https://stackoverflow.com/questions/8282017
复制相似问题