Set value to Context - Android android.content

Android examples for android.content:Context

Description

Set value to Context

Demo Code

import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.provider.ContactsContract;

public class Main {

  public static void setSuperPrimary(Context context, long dataId) {
    if (dataId == -1) {
      return;/* w  ww .j  ava 2s  .  c  o  m*/
    }

    // Update the primary values in the data record.
    ContentValues values = new ContentValues(2);
    values.put(ContactsContract.Data.IS_SUPER_PRIMARY, 1);
    values.put(ContactsContract.Data.IS_PRIMARY, 1);

    context.getContentResolver().update(ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, dataId), values,
        null, null);
  }

}

Related Tutorials