【发布时间】:2015-04-19 09:51:15
【问题描述】:
我通过使用这种方法从 android“我的”联系人中获得了姓名和联系人 ID
String[] columnNames = new String[] { Phone._ID,
Phone.DISPLAY_NAME };
Cursor c = LoginActivity.this.getContentResolver().query(
ContactsContract.Profile.CONTENT_URI, columnNames,
null, null, null);
int count = c.getCount();
boolean b = c.moveToFirst();
int position = c.getPosition();
if (count == 1 && position == 0) {
for (int j = 0; j < columnNames.length; j++) {
contact_id = c.getString(0);
namee = c.getString(1);
}
}
如何获取设备的电话号码?
【问题讨论】:
-
您需要在
columnNames数组中请求另一列。然后做c.getString(2);虽然我建议使用实际的字段名而不是索引。 -
您要保存在 ME 个人资料中的号码还是 sim 号码?
-
@Doomsknight 添加另一列时出现错误
-
您是否将
Phone.NUMBER添加到ColumnNames? -
@RahulPatil 我想要保存在我的联系人而不是 sim 号码的号码
标签: android contacts android-contacts phone-number