本文整理汇总了Java中android.provider.ContactsContract.Data.CONTACT_ID属性的典型用法代码示例。如果您正苦于以下问题:Java Data.CONTACT_ID属性的具体用法?Java Data.CONTACT_ID怎么用?Java Data.CONTACT_ID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.ContactsContract.Data
的用法示例。
在下文中一共展示了Data.CONTACT_ID属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContactLookupKeyByContactId
protected String getContactLookupKeyByContactId(String contactId) {
if (!SafeSlinger.doesUserHavePermission(Manifest.permission.READ_CONTACTS)) {
return null;
}
if (TextUtils.isEmpty(contactId)) {
return null;
}
String where = Data.CONTACT_ID + " = ?";
String[] whereParameters = new String[] {
contactId
};
Cursor c = getContentResolver().query(Data.CONTENT_URI, null, where, whereParameters, null);
if (c != null) {
try {
if (c.moveToFirst()) {
String lookup = c.getString(c.getColumnIndexOrThrow(Data.LOOKUP_KEY));
return lookup;
}
} finally {
c.close();
}
}
return null;
}
示例2: deleteMultipleContactsAtOnce
public void deleteMultipleContactsAtOnce(List<String> ids) {
String select = Data.CONTACT_ID + " = ?";
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
for (String id : ids) {
String[] args = new String[] { id };
ops.add(ContentProviderOperation.newDelete(ContactsContract.RawContacts.CONTENT_URI).withSelection(select, args).build());
}
ContentResolver cr = ContactsManager.getInstance().getContentResolver();
try {
cr.applyBatch(ContactsContract.AUTHORITY, ops);
} catch (Exception e) {
Log.e(e);
}
}
示例3: getContactsCursor
private Cursor getContactsCursor(ContentResolver cr) {
String req = "(" + Data.MIMETYPE + " = '" + CommonDataKinds.Phone.CONTENT_ITEM_TYPE
+ "' AND " + CommonDataKinds.Phone.NUMBER + " IS NOT NULL "
+ " OR (" + Data.MIMETYPE + " = '" + CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE
+ "' AND " + CommonDataKinds.SipAddress.SIP_ADDRESS + " IS NOT NULL))";
String[] projection = new String[] { Data.CONTACT_ID, Data.DISPLAY_NAME };
String query = Data.DISPLAY_NAME + " IS NOT NULL AND (" + req + ")";
Cursor cursor = cr.query(Data.CONTENT_URI, projection, query, null, " lower(" + Data.DISPLAY_NAME + ") COLLATE UNICODE ASC");
if (cursor == null) {
return cursor;
}
MatrixCursor result = new MatrixCursor(cursor.getColumnNames());
Set<String> groupBy = new HashSet<String>();
while (cursor.moveToNext()) {
String name = cursor.getString(cursor.getColumnIndex(Data.DISPLAY_NAME));
if (!groupBy.contains(name)) {
groupBy.add(name);
Object[] newRow = new Object[cursor.getColumnCount()];
int contactID = cursor.getColumnIndex(Data.CONTACT_ID);
int displayName = cursor.getColumnIndex(Data.DISPLAY_NAME);
newRow[contactID] = cursor.getString(contactID);
newRow[displayName] = cursor.getString(displayName);
result.addRow(newRow);
}
}
cursor.close();
return result;
}
示例4: getNameProjection
/**
* Get the NAME_PROJECTION for PhoneNumberPicker.
*/
public static String[] getNameProjection() {
String[] nameProjection = {
Data.CONTACT_ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.PHOTO_THUMBNAIL_URI,
Phone.NUMBER,
};
return nameProjection;
}
示例5: queryStep2
private void queryStep2(List<PhoneBean> beans, HashMap<Long, PhoneBean> phones) {
final String[] PROJ_DATA = new String[] {
Data._ID,
Data.CONTACT_ID,
Data.DATA1,
};
Cursor dataCursor = getContentResolver().query(Data.CONTENT_URI,
PROJ_DATA,
Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
null, DATA_QUERY_ORDER);
long dataId, contactId;
String number;
PhoneBean bean;
try {
dataCursor.moveToPosition(-1);
while(dataCursor.moveToNext()) {
dataId = dataCursor.getLong(0);
contactId = dataCursor.getLong(1);
number = dataCursor.getString(2);
bean = new PhoneBean(dataId, number);
beans.add(bean);
//same contactId save one phoneBean
phones.put(contactId, bean);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if(dataCursor != null) {
dataCursor.close();
}
}
}
示例6: updateContactIdFromUri
public static void updateContactIdFromUri(Uri uri) {
ContactDetailFragment.SelectedContactID = uri.getLastPathSegment();
ContactDetailFragment.CONTACT_PHONE_QUERY_SELECTION = Data.CONTACT_ID + "=" + ContactDetailFragment.SelectedContactID;
}
示例7: queryStep1
private void queryStep1(HashMap<String, ArrayList<ContactBean>> contactsMap) {
final String[] PROJ_DATA = new String[] {
Data._ID,
Data.CONTACT_ID,
Data.DATA1,
Contacts.DISPLAY_NAME
};
Cursor dataCursor = getContentResolver().query(Data.CONTENT_URI,
PROJ_DATA,
Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
null, DATA_QUERY_ORDER);
long dataId, contactId;
String number, name;
PhoneBean phoneBean;
ContactBean contactBean;
ArrayList<ContactBean> tempSameBeans;
try {
dataCursor.moveToPosition(-1);
while(dataCursor.moveToNext()) {
dataId = dataCursor.getLong(0);
contactId = dataCursor.getLong(1);
number = dataCursor.getString(2);
name = dataCursor.getString(3);
phoneBean = new PhoneBean(dataId, number);
contactBean = new ContactBean(contactId, name);
contactBean.addNumber(phoneBean);
if(contactsMap.containsKey(name)) {
tempSameBeans = contactsMap.get(name);
if(!tempSameBeans.contains(contactBean)) {
tempSameBeans.add(contactBean);
}
} else {
tempSameBeans = new ArrayList<ContactBean>();
tempSameBeans.add(contactBean);
contactsMap.put(name, tempSameBeans);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if(dataCursor != null) {
dataCursor.close();
}
}
}