I have made some experiments here and found that this labels google/
phone are not about grouping - there is undocumented "type" column in
the People table which seems to be responcible for this.
The following code:
final Cursor pcur = context.managedQuery(Contacts.People.CONTENT_URI,
null, null, null, null);
while (pcur.moveToNext()) {
Log.d("#############",
"**************************************");
for (int i = 0; i < pcur.getColumnCount(); i++) {
Log.d("#############", pcur.getColumnName(i) +
"="
+ pcur.getString(i));
}
}
pcur.close();
Prints the following:
D/#############(18621): sort_string=MILO
�
D/#############(18621):
primary_organization=null
D/#############(18621):
lastName=null
D/#############(18621):
number=4167103
D/#############(18621):
number_key=3017614
D/#############(18621):
times_contacted=0
D/#############(18621):
_sync_dirty=1
D/#############(18621):
im_account=null
D/#############(18621):
last_time_contacted=null
D/#############(18621):
_id=1197
D/#############(18621):
picasaUrl=null
D/#############(18621):
type=2
D/#############(18621):
extra_group=2
D/#############(18621):
notes=null
D/#############(18621):
display_name=Milo
D/#############(18621):
_sync_version=null
D/#############(18621):
starred=0
D/#############(18621):
status=null
D/#############(18621):
phonetic_name=null
D/#############(18621):
mode=null
D/#############(18621):
_sync_account=null
D/#############(18621):
label=null
D/#############(18621): firstName=null
D/#############(18621): custom_ringtone=null
D/#############(18621): im_protocol=null
D/#############(18621): _sync_time=null
D/#############(18621): _sync_id=null
D/#############(18621): im_handle=null
D/#############(18621): send_to_voicemail=null
D/#############(18621): name=Milo
D/#############(18621): primary_email=null
D/#############(18621): _sync_local_id=null
D/#############(18621): last_update_time=null
D/#############(18621): default_action=null
D/#############(18621): primary_phone=954
the "type" column value is '0' for contacts with "google label" and
'2' for contacts with "phone" label.
This could be fine - just set "type" column value to '2' when add
contact and it should appear with "phone" label in contact book:
public static final String CONTACT_TYPE = "type";
public static final int CONTACT_TYPE_GOOGLE = 0;
public static final int CONTACT_TYPE_PHONE = 2;
final ContentValues peopleValues = new ContentValues();
peopleValues.put(CONTACT_TYPE, CONTACT_TYPE_PHONE);
final Uri personUri = context.getContentResolver().insert(
Contacts.People.CONTENT_URI, peopleValues);
final long contactId = ContentUris.parseId(personUri);
Contacts.People.addToMyContactsGroup(context.getContentResolver(),
contactId);
but this code gives me the following exception:
E/DatabaseUtils(17695): Writing exception to
parcel
E/DatabaseUtils(17695): java.lang.IllegalArgumentException: column
'type' is
invalid
E/DatabaseUtils(17695): at android.database.DatabaseUtils
$InsertHelper.getColumnIndex(DatabaseUtils.java:
794)
E/DatabaseUtils(17695): at android.database.DatabaseUtils
$InsertHelper.insertInternal(DatabaseUtils.java:
770)
E/DatabaseUtils(17695): at android.database.DatabaseUtils
$InsertHelper.insert(DatabaseUtils.java:
898)
E/DatabaseUtils(17695): at
com.android.providers.contacts.ContactsProvider.insertInternal
(ContactsProvider.java:5260)
E/DatabaseUtils(17695): at
android.content.AbstractSyncableContentProvider.insert
(AbstractSyncableContentProvider.java:
298)
E/DatabaseUtils(17695): at android.content.ContentProvider
$Transport.insert(ContentProvider.java:
140)
E/DatabaseUtils(17695): at
android.content.ContentProviderNative.onTransact
(ContentProviderNative.java:
125)
E/DatabaseUtils(17695): at android.os.Binder.execTransact
(Binder.java:
287)
E/DatabaseUtils(17695): at dalvik.system.NativeStart.run
(Native
Method)
What is wrong here?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en