1

问题1。

我有这堂课:

public class ContactGroups {

    // Form an array specifying which columns to return.
    String[] projection = new String[] { Contacts.Groups._ID,
            Contacts.Groups._COUNT, Contacts.Groups.NAME, Contacts.Groups.NOTES };

    public Cursor getList(Activity act) {

        Uri contacts = Contacts.Groups.CONTENT_URI;
             // using the debugger code kills here
            Cursor managedCursor = act.managedQuery(contacts, projection, 
                null, 
                null 
             , null
                );
        return managedCursor;
    }

    public ArrayList<String> getColumnData(Cursor cur) {
        ArrayList<String> aa = new ArrayList<String>();
        if (cur.moveToFirst()) {

            String name;
            String notes;
            int nameColumn = cur.getColumnIndex(Contacts.Groups.NAME);
            int notesColumn = cur.getColumnIndex(Contacts.Groups.NOTES);

            do {
                // Get the field values
                name = cur.getString(nameColumn);
                notes = cur.getString(notesColumn);
                aa.add(name);
                // Do something with the values.

            } while (cur.moveToNext());

        }
        return aa;
    }

}

我称之为:

ContactGroups mGrp= new ContactGroups();
final ArrayAdapter<String> aa;
aa = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,mGrp.getColumnData(mGrp.getList(this)));
myListView.setAdapter(aa);

并拥有:

<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>

我收到 Source not found 错误和 Logcat 错误

ERROR/DatabaseUtils(617): java.lang.IllegalArgumentException: Invalid column _count

有人知道为什么吗?

问题 2。

在哪里手动创建联系人组?

4

1 回答 1

1

Contacts.Groups已弃用。您应该使用ContactsContract

您可能感兴趣的常量在ContactsContract.Groups下,特别是针对计数的SUMMARY_COUNT

于 2010-02-26T16:09:53.807 回答