1

嗨,我正在联系人应用程序上做一个应用程序我使用下面的代码获得了联系人 ID 和显示名称现在我想要的是公司名称单独与联系人 ID 和显示名称。我怎样才能获得公司名称?

    private void populateContactList() {
    // Build adapter with contact entries

    Cursor cursor = getContacts();
    fields = new String[] { ContactsContract.Data.DISPLAY_NAME,
            ContactsContract.Contacts._ID};



    contactqueryAdaptor = new Contactquery_adaptor(this, R.layout.row,
            cursor, fields, new int[] { R.id.applese });




}

//getContacts()

    private Cursor getContacts() {
    // Run query
    Uri uri = ContactsContract.Contacts.CONTENT_URI;
    String[] projection = new String[] { ContactsContract.Contacts._ID,
            ContactsContract.Contacts.DISPLAY_NAME};
    String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '"
            + (mShowInvisible ? "0" : "1") + "'";
    String[] selectionArgs = null;
    String sortOrder = ContactsContract.Contacts.DISPLAY_NAME
            + " COLLATE LOCALIZED ASC";


    return managedQuery(uri, projection, selection, selectionArgs,
            sortOrder);
}
4

1 回答 1

1

根据此:Get company name form Content Provider in android using new API's,您需要查询 ContactsContract.Data 并使用这些别名http://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds。组织.html

于 2012-09-19T12:05:33.470 回答