xingyan

下面展示一段在Android1.5上读取手机通讯录的代码

 

1 //链接通讯录数据库
2   ContentResolver content = getContentResolver();
3 Cursor cursor = content.query(Contacts.People.CONTENT_URI, null, null, null, null);
4 //保存用户名信息
5   String[] nameList = new String[cursor.getCount()];
6 //遍历通讯录
7   for(int i=0; i<cursor.getCount() ;i++)
8 {
9 cursor.moveToPosition(i);
10 //获取人名
11 nameList[i] = cursor.getString(cursor.getColumnIndexOrThrow(Contacts.People.NAME));
12 //获取电话
13 nameList[i] += ":" + cursor.getString(cursor.getColumnIndexOrThrow(Contacts.People.NUMBER));
14 }

 

 

读取到的通讯录显示在一个ListView上边 如下图

分类:

技术点:

相关文章:

  • 2021-12-15
  • 2021-11-28
  • 2021-12-15
  • 2021-07-07
  • 2021-10-14
  • 2021-06-28
  • 2021-09-19
猜你喜欢
  • 2021-12-15
  • 2021-07-13
  • 2021-12-15
  • 2021-04-30
  • 2021-08-16
  • 2021-12-29
  • 2021-04-20
相关资源
相似解决方案