首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

通讯录有关

2012-06-27 
通讯录相关1.查看所有联系人信息ContentResolver cr mContext.getContentResolver()Cursor cursor cr

通讯录相关

1.查看所有联系人信息

ContentResolver cr = mContext.getContentResolver();Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI ,null,null,null,null);while(cursor.moveToNext()){for (int i = 0, count = cursor.getColumnCount(); i < count; i++){Log.v("TAG", "column:" + cursor.getColumnName(i) + ",value:" + cursor.getString(i));}}
?

2.查询通过话的联系人,并按最后一次通话的时间排序(注意,如果通话对象不存在于联系人中,则没有)

?

ContentResolver cr = mContext.getContentResolver();Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI , null, "times_contacted > 0 ", null, "last_time_contacted desc");while (cursor.moveToNext()){ContentResolver cr = mContext.getContentResolver();Cursor cursor = cr.query(CallLog.Calls.CONTENT_URI , null, " _id in (select _id from calls group by number order by date desc )", null, "date desc");while (cursor.moveToNext()){for (int i = 0, count = cursor.getColumnCount(); i < count; i++){Log.v("TAG", "column:" + cursor.getColumnName(i) + ",value:" + cursor.getString(i));}}?for (int i = 0, count = cursor.getColumnCount(); i < count; i++){Log.v("TAG", "column:" + cursor.getColumnName(i) + ",value:" + cursor.getString(i));}}
?

3.查询出所有的最近的不重复的通话记录(包括不存在于联系人中的),并按时间排序,但是没有通话的次数

?

?

ContentResolver cr = mContext.getContentResolver();Cursor cursor = cr.query(CallLog.Calls.CONTENT_URI , null, " _id in (select _id from calls group by number order by date desc )", null, "date desc");while (cursor.moveToNext()){for (int i = 0, count = cursor.getColumnCount(); i < count; i++){Log.v("TAG", "column:" + cursor.getColumnName(i) + ",value:" + cursor.getString(i));}          }
?

?

?

?

?

?

?

热点排行