Get all contacts and their details (e.g. postal address) in one OUTER JOIN query

前端 未结 2 949
半阙折子戏
半阙折子戏 2021-01-20 16:18

I know how to retrieve contact data for specific contacts. However, i can\'t find a way to get all contacts plus some of their details in a single query. The following code

2条回答
  •  后悔当初
    2021-01-20 16:37

    All contact information in Android 2.0 is stored in a single database table. So you can get all the information you need in a single query:

    Cursor c = getContentResolver().query(ContactsContract.Data.CONTENT_URI,
        null, null, null, sortOrder);
    

    The just iterate through the data and check Data.MIMETYPE column. For example, if this column has StructuredPostal.CONTENT_ITEM_TYPE value, then you can get StructuredPostal fields from this column.

提交回复
热议问题