androidandroid-sdk-2.1contactgroups

Getting really weird long Contact Group names


When looking at the Contact Groups on Google Contacts or in the People application of my HTC Legend phone, I get the groups names ok eg: Friends, Family, VIP, Favorite etc...

But in my application I get really wrong names such as
"Family" became "System Group: Family"
"Friends" became "System Group: Friends"
"Favorite" became "Favorite_5656100000000_3245664334564"

I use the below code to read these values:

public Cursor getFromSystem() {

        // Get the base URI for the People table in the Contacts content
        // provider.
        Uri contacts = ContactsContract.Groups.CONTENT_URI;
        // Make the query.
        ContentResolver cr = ctx.getContentResolver();
        // Form an array specifying which columns to return.
        String[] projection = new String[] {
                ContactsContract.Groups._ID, ContactsContract.Groups.TITLE,
                ContactsContract.Groups.NOTES
        };

        Cursor managedCursor = cr.query(contacts, projection, ContactsContract.Groups.DELETED
                + "=0", null, ContactsContract.Groups.TITLE + " COLLATE LOCALIZED ASC");
        return managedCursor;
    }

What I am missing?


Solution

  • That sounds like a bug. One of my test phones has correct/sanitized titles, while the other has that type of incorrect title. I'd file this here.

    I also inspected the contacts2.db database directly, and found that the SYSTEM_ID column seems to be sanitized – but that's probably not safe to use for display purposes.