I'm trying to make a similar ContentProvider reading as in android developer guide- read from user dictionary. I can't get why my cursor has always 0 rows.. Of course I've added a needed permission. I was trying to change nulls to empty arrays or simmilar things, but it is not working. Any idea?
There is my source code
public void sampleMethodWithContentProviders() {
// String contentUriStr = "content://user_dictionary/words";
// Uri wordsUri = Uri.parse(contentUriStr);
String[] projectionString = {
UserDictionary.Words._ID,
UserDictionary.Words.WORD,
UserDictionary.Words.LOCALE
};
String selectClause = null;
String[] selectArgs = null;
String order = null;
Cursor cursor = getContentResolver().query(UserDictionary.Words.CONTENT_URI, projectionString, selectClause, selectArgs, order);
Log.i("Cursor", cursor == null ? "null" : "obiekt");
for (String s : cursor.getColumnNames())
Log.i("Cursor column name: ", s);
Log.i("Num of cursor element: ", Integer.toString(cursor.getCount()));
while (cursor.moveToNext())
Log.i("a", "b");
}
And there the logs result
12-01 00:02:54.530 11693-11693/com.kros.withoutpain I/Cursor: obiekt 12-01 00:02:54.530 11693-11693/com.kros.withoutpain I/Cursor column name:: _id 12-01 00:02:54.530 11693-11693/com.kros.withoutpain I/Cursor column name:: word 12-01 00:02:54.530 11693-11693/com.kros.withoutpain I/Cursor column name:: locale 12-01 00:02:54.530 11693-11693/com.kros.withoutpain I/Num of cursor element:: 0