异常。 java.lang.IllegalStateException:无法从CursorWindow读取第0行col -1。在从中访问数据之前,请确保Cursor已正确初始化。
我可以阅读DISPLAY_NAME或_ID。相同的代码适用于运行5.0的LG设备。有什么帮助吗?
try{
Cursor cursor = null;
ContentResolver contentResolver = getContentResolver();
cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
while (cursor.moveToNext()) {
String id = cursor.getString(
cursor.getColumnIndex(ContactsContract.Contacts._ID));
String name = cursor.getString(
cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String account = cursor.getString(
cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_NAME));
String ty = cursor.getString(
cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE));
}
}
catch (Exception ex)
{
Log.e("CONTACTS",ex.toString());
}
finally {
}