/** * Return the ID of the first raw-contact in the contact data that belongs to a * contact-writable account, or -1 if no such entity exists. */ public long getFirstWritableRawContactId(final Context context) { // Directory entries are non-writable if (isDirectoryEntry()) return -1; // Iterate through raw-contacts; if we find a writable on, return its ID. for (RawContact rawContact : getRawContacts()) { AccountType accountType = rawContact.getAccountType(context); if (accountType != null && accountType.areContactsWritable()) { return rawContact.getId(); } } // No writable raw-contact was found. return -1; }
@Override public void deliverResult(Contact result) { unregisterObserver(); // The creator isn't interested in any further updates if (isReset() || result == null) { return; } mContact = result; if (result.isLoaded()) { mLookupUri = result.getLookupUri(); if (!result.isDirectoryEntry()) { Log.i(TAG, "Registering content observer for " + mLookupUri); if (mObserver == null) { mObserver = new ForceLoadContentObserver(); } getContext().getContentResolver().registerContentObserver( mLookupUri, true, mObserver); } if (mPostViewNotification) { // inform the source of the data that this contact is being looked at postViewNotificationToSyncAdapter(); } } super.deliverResult(mContact); }
if (result.isDirectoryEntry()) { if (!resultIsCached) { loadDirectoryMetaData(result);