升序加载电话联系人 [英] Loading phone contacts in ascending order

查看:124
本文介绍了升序加载电话联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试加载电话联系人,并尝试按升序显示联系人姓名.我的代码如下:

I am trying to load phone contacts and tried to show the contact names in ascending order. My code is given below:

    Cursor cursor = getContentResolver().query(
    ContactsContract.Contacts.CONTENT_URI, null,
    ContactsContract.Contacts.HAS_PHONE_NUMBER + " = 1", null,
    ContactsContract.Contacts.DISPLAY_NAME + " ASC");

我得到了所需的输出.但是存在一个问题,用小写字母开头的名称显示为最后一个.首先,对大写字母进行排序,仅在显示带有小写字母的联系人姓名之后.PLS帮助

I got the required output. But a problem is there, names staring with small letter is shown as last one. First the capital letters are sorted, only after that contact names staring with small letters is shown. PLS HELP

输出是:

Alfin A
Bipin B
Calvin C
Jobin
Shine
anurag U
shine H

推荐答案

Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null,
   ContactsContract.Contacts.HAS_PHONE_NUMBER + " = 1", 
   null, 
   "UPPER(" + ContactsContract.Contacts.DISPLAY_NAME + ") ASC");

这篇关于升序加载电话联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆