在android中按字母顺序获取联系人?
我想按字母顺序获取联系人,但此查询按非字母顺序获取联系人。我不知道在此查询中将asc订单附加到何处。请帮助第五个参数是sortOrder。您正在传递在android中按字母顺序获取联系人?,android,mysql,Android,Mysql,我想按字母顺序获取联系人,但此查询按非字母顺序获取联系人。我不知道在此查询中将asc订单附加到何处。请帮助第五个参数是sortOrder。您正在传递数据。请联系\u ID Cursor cursor = contentResolver.query(Data.CONTENT_URI, null, "(" + Data.MIMETYPE + "=? OR " + Data.MIMETYPE+ "=?) AND " + Data.CONTACT_ID + " IN (SELECT " + Contac
数据。请联系\u ID
Cursor cursor = contentResolver.query(Data.CONTENT_URI, null, "(" + Data.MIMETYPE + "=? OR " + Data.MIMETYPE+ "=?) AND " + Data.CONTACT_ID + " IN (SELECT " + Contacts._ID + " FROM contacts)", new String[] {Email.CONTENT_ITEM_TYPE, Phone.CONTENT_ITEM_TYPE }, Data.CONTACT_ID);
|*|在查询的5个参数中添加下一行,因为它是用于排序顺序的
Cursor cursor = contentResolver.query(Data.CONTENT_URI, null, "(" + Data.MIMETYPE + "=? OR " + Data.MIMETYPE+ "=?) AND " + Data.CONTACT_ID + " IN (SELECT " + Contacts._ID + " FROM contacts)", new String[] {Email.CONTENT_ITEM_TYPE, Phone.CONTENT_ITEM_TYPE }, Data.DISPLAY_NAME+" ASC");
|*|优化:按字母顺序通过标签和照片缩略图在一次查询中获取显示名称和编号:
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC"
谢谢你的回复,工作很好,但比我上次询问的时间要长。不客气。如果您觉得我的回答有助于您继续前进并回答您的问题,请将其标记为“已接受”好吗?谢谢
ContentResolver contentResolver = getContentResolver();
Cursor contctKsrVar = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
new String[] {
ContactsContract.CommonDataKinds.Phone._ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.TYPE,
ContactsContract.CommonDataKinds.Phone.LABEL,
ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI},
null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC");