Android 读取联系人号码
我正在尝试这个
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null,
null, null, null);
Cursor cursor1 = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
null, null, null);
int nameIdx = cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME);
int phoneIdx = cursor1.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER);
if (cursor.moveToFirst())
do {
// Extract the name.
String name = cursor.getString(nameIdx);
// Extract the phone number.
String phone = cursor.getString(phoneIdx);
Log.i("ContentProvider", name);
Log.i("ContentProvider", phone);
} while (cursor.moveToNext());
我可以读取名称但数字我收到错误
I am trying this
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null,
null, null, null);
Cursor cursor1 = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
null, null, null);
int nameIdx = cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME);
int phoneIdx = cursor1.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER);
if (cursor.moveToFirst())
do {
// Extract the name.
String name = cursor.getString(nameIdx);
// Extract the phone number.
String phone = cursor.getString(phoneIdx);
Log.i("ContentProvider", name);
Log.i("ContentProvider", phone);
} while (cursor.moveToNext());
I am able to read Names but Numbers i am getting an error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
完成本教程,这可以帮助您解决问题
链接如下:
http://developer.android.com/resources/samples/ContactManager/index.html
Get through this tutorial, this could help you out of your problem
Link is provided as below:
http://developer.android.com/resources/samples/ContactManager/index.html