Java ContentProvider未返回数据
因此,我有一个简单的方法从字典中获取所有单词:Java ContentProvider未返回数据,java,android,android-contentprovider,cursors,Java,Android,Android Contentprovider,Cursors,因此,我有一个简单的方法从字典中获取所有单词: public static void getFromDictionary(Activity a) { System.out.println("Inside getFromDictionary"); ContentResolver resolver = a .getContentResolver(); String[] projection = new String[]
public static void getFromDictionary(Activity a) {
System.out.println("Inside getFromDictionary");
ContentResolver resolver = a
.getContentResolver();
String[] projection = new String[] { UserDictionary.Words._ID,
UserDictionary.Words.WORD, UserDictionary.Words.FREQUENCY };
Cursor cursor = resolver.query(UserDictionary.Words.CONTENT_URI,
projection, null, null, null);
while (cursor.moveToNext()) {
String word = cursor.getString(1);
Log.e("DICCIONARIO", word);
}
}
好吧,我在不同的手机上试过了,但是while bucle无法进入(光标中没有任何内容)。
我做错了什么?尝试将您的投影列表限制为只有一项,即UserDictionary.Words.\u ID
或者将null作为投影参数您确定用户字典中有单词吗?我不知道!我怎么检查?我试过3部不同的手机…进入手机的设置,进入语言和输入,然后进入个人词典。你可以在那里添加单词。