文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>[Android] Contacts

[Android] Contacts

时间:2010-08-06  来源:web_surf

  1. Read Contacts after sdk 2.0
    Refer to:
    http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/
    http://stackoverflow.com/questions/1721279/how-to-read-contacts-on-android-2-0
    Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, 
    null, null, null, null);
    while (cursor.moveToNext()) {
    String contactId = cursor.getString(cursor.getColumnIndex(
    ContactsContract.Contacts._ID));
    String hasPhone = cursor.getString(cursor.getColumnIndex(
    ContactsContract.Contacts.HAS_PHONE_NUMBER));
    if (Boolean.parseBoolean(hasPhone)) {
    // You know have the number so now query it like this
    Cursor phones = getContentResolver().query(
    ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
    null,
    ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId,
    null, null);
    /*
    Or
    Cursor phones = getContentResolver().query(
    ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
    null,
    ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
    new String[]{contactId
    }, null);
    */
    while (phones.moveToNext()) {
  2.      String phoneNumber = phones.getString( 
    phones
    .getColumnIndex(
    ContactsContract.CommonDataKinds.Phone.NUMBER));
    }
    phones
    .close();
    }
    Cursor emails = getContentResolver().query(
    ContactsContract.CommonDataKinds.Email.CONTENT_URI,
    null,
    ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + contactId,
    null, null);
    while (emails.moveToNext()) {
    // This would allow you get several email addresses
    String emailAddress = emails.getString(
    emails
    .getColumnIndex(
    ContactsContract.CommonDataKinds.CommonDataColumns.DATA));
    }
    emails
    .close();
    }
    cursor
    .close();

  3. xxx
相关阅读 更多 +
排行榜 更多 +
我是班长去广告版下载

我是班长去广告版下载

模拟经营 下载
什么鸭小游戏安卓版下载

什么鸭小游戏安卓版下载

策略塔防 下载
极光影院官方最新版本2025下载

极光影院官方最新版本2025下载

趣味娱乐 下载