我正在将列表中的帐户名传递给此方法。现在我想知道哪些帐户名称在联系人表中是只读的,所以我只迭代游标一次以从原始游标中获取联系人 ID。获得contact_id后,我正在使用手机光标检查给定的id是否为只读,但我无法做到。请看下面
private void displayAllContactsByType(String accountName) {
Cursor rawCursor,phones = null;
rawCursor = cResolver.query(
ContactsContract.RawContacts.CONTENT_URI,
new String[]{ContactsContract.RawContacts.CONTACT_ID},
ContactsContract.RawContacts.ACCOUNT_NAME + "= ?",
new String[]{accountName},
null);
int contactIdColumn = rawCursor.getColumnIndex(ContactsContract.RawContacts.CONTACT_ID);
int rawCursorCount = rawCursor.getCount();
Utils.Log("Account Name", accountName);
Utils.Log("Raw Size", " " + rawCursorCount);
rawCursor.moveToFirst();
Long contactId = rawCursor.getLong(contactIdColumn);
phones = cResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ? AND "+ContactsContract.RawContacts.ACCOUNT_NAME + "= ?",
new String[]{String.valueOf(contactId),accountName},
null);
phones.moveToFirst();
String isReadOnly= phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.IS_READ_ONLY));
Utils.Log("Raw Size", isReadOnly);
}