diff options
| author | Android (Google) Code Review <android-gerrit@google.com> | 2009-09-02 08:38:32 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-09-02 08:38:32 -0700 |
| commit | bb54f93ff66f382dc706b9fff508d386e046fdc2 (patch) | |
| tree | bb37b4c405e4646ddb2d43b9bd3656cb216b56ac /core | |
| parent | 14d8e6e5d5503fe420bb3276d367cba1bfba03f9 (diff) | |
| parent | b5759b5f4f01771a615c100c1d87adc702a6ef71 (diff) | |
| download | frameworks_base-bb54f93ff66f382dc706b9fff508d386e046fdc2.zip frameworks_base-bb54f93ff66f382dc706b9fff508d386e046fdc2.tar.gz frameworks_base-bb54f93ff66f382dc706b9fff508d386e046fdc2.tar.bz2 | |
Merge change 23527 into eclair
* changes:
Adding a convenience method to resolve contact lookup URI to a regular content URI
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/provider/ContactsContract.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index 9dfab99..2b67946 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -289,6 +289,32 @@ public final class ContactsContract { } /** + * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. + * <p> + * Returns null if the contact cannot be found. + */ + public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { + if (lookupUri == null) { + return null; + } + + Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); + if (c == null) { + return null; + } + + try { + if (c.moveToFirst()) { + long contactId = c.getLong(0); + return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); + } + } finally { + c.close(); + } + return null; + } + + /** * The content:// style URI for this table joined with useful data from * {@link Data}. * |
