/// <summary> /// Attempts to load a contact for the specified <paramref name="id" />. /// </summary> /// <param name="id"></param> /// <returns>The <see cref="Contact" /> if found, <c>null</c> otherwise.</returns> /// <exception cref="ArgumentNullException"><paramref name="id" /> is <c>null</c>.</exception> /// <exception cref="ArgumentException"><paramref name="id" /> is empty.</exception> public IContact Load(String id) { if (id == null) { throw new ArgumentNullException("id"); } if (id.Trim() == String.Empty) { throw new ArgumentException("Invalid ID", "id"); } Uri curi; String column; if (PreferContactAggregation) { curi = ContactsContract.Contacts.ContentUri; column = ContactsContract.ContactsColumns.LookupKey; } else { curi = ContactsContract.RawContacts.ContentUri; column = ContactsContract.RawContactsColumns.ContactId; } ICursor c = null; try { c = content.Query(curi, null, column + " = ?", new[] { id }, null); return(c.MoveToNext() ? ContactHelper.GetContact(!PreferContactAggregation, content, resources, c) : null); } finally { if (c != null) { c.Deactivate(); } } }