コード例 #1
0
  public long createRawContact() {
    ensureCallingPackage();
    final ContentValues values = new ContentValues();

    Uri rawContactUri = resolver.insert(RawContacts.CONTENT_URI, values);
    return ContentUris.parseId(rawContactUri);
  }
コード例 #2
0
 //    public long createRawContactWithStatus(String name, String address,
 //            String status) {
 //        final long rawContactId = createRawContact(name);
 //        final long dataId = createEmail(rawContactId, address);
 //        createStatus(dataId, status);
 //        return rawContactId;
 //    }
 //
 public long createName(long contactId, String name) {
   ensureCallingPackage();
   final ContentValues values = new ContentValues();
   values.put(Data.RAW_CONTACT_ID, contactId);
   values.put(Data.IS_PRIMARY, 1);
   values.put(Data.IS_SUPER_PRIMARY, 1);
   values.put(Data.MIMETYPE, CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
   values.put(CommonDataKinds.StructuredName.FAMILY_NAME, name);
   Uri insertUri =
       Uri.withAppendedPath(
           ContentUris.withAppendedId(RawContacts.CONTENT_URI, contactId),
           RawContacts.Data.CONTENT_DIRECTORY);
   Uri dataUri = resolver.insert(insertUri, values);
   return ContentUris.parseId(dataUri);
 }
コード例 #3
0
 public long createEmail(long contactId, String address) {
   ensureCallingPackage();
   final ContentValues values = new ContentValues();
   values.put(Data.RAW_CONTACT_ID, contactId);
   values.put(Data.IS_PRIMARY, 1);
   values.put(Data.IS_SUPER_PRIMARY, 1);
   values.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
   values.put(Email.TYPE, Email.TYPE_HOME);
   values.put(Email.DATA, address);
   Uri insertUri =
       Uri.withAppendedPath(
           ContentUris.withAppendedId(RawContacts.CONTENT_URI, contactId),
           RawContacts.Data.CONTENT_DIRECTORY);
   Uri dataUri = resolver.insert(insertUri, values);
   return ContentUris.parseId(dataUri);
 }