Android获取所有联系人列表(姓名,电子邮件,电话)需要超过一分钟的约700个联系人
有没有办法缩短这个时间?我正在使用光标运行并获取姓名,电话号码和电子邮件
如果我从查询循环中删除电话号码查询,它将在3秒后结束
任何想法如何改进该查询?
也许我在查询中做错了什么?
(显然我正在做异步但仍然......用户已经很长时间不能等了)
希望有人可以分享他对此的看法
这是我的代码
ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if (cur.getCount() > 0) { while (cur.moveToNext()) { AddressBookEntity adr = new AddressBookEntity(); String id = cur.getString(cur .getColumnIndex(ContactsContract.Contacts._ID)); String name = cur .getString(cur .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); adr.fullName = name; Cursor emailCur = cr .query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?", new String[] { id }, null); while (emailCur.moveToNext()) { // This would allow you get several email addresses // if the email addresses were stored in an array String email = emailCur .getString(emailCur .getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA)); if (!Utils.IsNullOrEmptyString(email)) { adr.email = email; } }
FFIVE
相关分类