From 6e9610e1dba59bf708b45e0039856d70e6b9768b Mon Sep 17 00:00:00 2001 From: Daisuke Miyakawa Date: Tue, 19 May 2009 08:51:39 +0900 Subject: [PATCH] Fix build breakage --- core/java/android/provider/Contacts.java | 34 ++++++++++++++---------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/core/java/android/provider/Contacts.java b/core/java/android/provider/Contacts.java index 8d6ebdd61ddaf..84fe1841888ec 100644 --- a/core/java/android/provider/Contacts.java +++ b/core/java/android/provider/Contacts.java @@ -339,28 +339,34 @@ public class Contacts { resolver.update(uri, values, null, null); } + /** + * @hide Used in vCard parser code. + */ + public static long tryGetMyContactsGroupId(ContentResolver resolver) { + Cursor groupsCursor = resolver.query(Groups.CONTENT_URI, GROUPS_PROJECTION, + Groups.SYSTEM_ID + "='" + Groups.GROUP_MY_CONTACTS + "'", null, null); + if (groupsCursor != null) { + try { + if (groupsCursor.moveToFirst()) { + return groupsCursor.getLong(0); + } + } finally { + groupsCursor.close(); + } + } + return 0; + } + /** * Adds a person to the My Contacts group. - * + * * @param resolver the resolver to use * @param personId the person to add to the group * @return the URI of the group membership row * @throws IllegalStateException if the My Contacts group can't be found */ public static Uri addToMyContactsGroup(ContentResolver resolver, long personId) { - long groupId = 0; - Cursor groupsCursor = resolver.query(Groups.CONTENT_URI, GROUPS_PROJECTION, - Groups.SYSTEM_ID + "='" + Groups.GROUP_MY_CONTACTS + "'", null, null); - if (groupsCursor != null) { - try { - if (groupsCursor.moveToFirst()) { - groupId = groupsCursor.getLong(0); - } - } finally { - groupsCursor.close(); - } - } - + long groupId = tryGetMyContactsGroupId(resolver); if (groupId == 0) { throw new IllegalStateException("Failed to find the My Contacts group"); }