blob: 1bd08aa90abc520ca258e4ce14a11e6b4439c7d5 [file] [log] [blame]
Chiao Cheng32984642012-10-24 15:19:31 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.contacts.common.database;
18
19import android.content.ContentUris;
20import android.content.ContentValues;
21import android.content.Context;
22import android.provider.ContactsContract;
23import android.util.Log;
24
25/**
26 * Static methods to update contact information.
27 */
28public class ContactUpdateUtils {
29
30 private static final String TAG = ContactUpdateUtils.class.getSimpleName();
31
32 public static void setSuperPrimary(Context context, long dataId) {
33 if (dataId == -1) {
34 Log.e(TAG, "Invalid arguments for setSuperPrimary request");
35 return;
36 }
37
38 // Update the primary values in the data record.
39 ContentValues values = new ContentValues(2);
40 values.put(ContactsContract.Data.IS_SUPER_PRIMARY, 1);
41 values.put(ContactsContract.Data.IS_PRIMARY, 1);
42
43 context.getContentResolver().update(
44 ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, dataId),
45 values, null, null);
46 }
47}