显示联系人的排序内容解析器秩序ContactsContract.Contacts秩序、联系人、内容、Contacts

2023-09-06 09:40:45 作者:[遙遠的她]

我的目的是要显示在联系人的排序顺序使用内容解析 android系统。

My intention is to display the contacts in sorting order using content resolver in android.

对于我写:

Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
                            ContactsContract.CommonDataKinds.Phone.CONTACT_ID+ " = ?", new String[] { id }, null);

它需要在查询方法的最后一个参数不应该是由名称排序元素空。其中code部分我必须更换空参数,实现按名称排序?或者,请帮我查询在这种情况下...

It needs that the last parameter in query method should not be null for sorting the elements by Name. Which part of code I have to replace the null parameter to achieve sorting by name ? Or please help me querying in such a case...

在此先感谢

推荐答案

要根据名称使用排序结果 Phone.DISPLAY_NAME 常量 ASC 作为最后一个参数查询方法。做到这一点的:

To sort result according to name use Phone.DISPLAY_NAME constant with ASC as last parameter to query method. do it as:

  Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, 
                   null, 
                   ContactsContract.CommonDataKinds.Phone.CONTACT_ID+ " = ?",
                   new String[] { id },
                   ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME+" ASC");