如何查询UserDictionary内容提供商在Android? [英] How to query UserDictionary content provider on Android?
本文介绍了如何查询UserDictionary内容提供商在Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎无法找到如何查询给出一个字UserDictionary内容提供商的任何很好的例子,code。我的查询是这样的:
I can't seem to find any good example code of how to query the UserDictionary content provider given a word. My query looks like:
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
在我的清单。
推荐答案
试试这个
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);
我没有测试过这一点,只是一个建议
I have not tested this, just a suggestion
这篇关于如何查询UserDictionary内容提供商在Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文