private void getSimContacts(String str){ |
Intent intent = new Intent(); |
intent.setData(Uri.parse(str)); |
Uri uri = intent.getData(); |
mCursor = getContentResolver().query(uri, null , null , null , null ); |
if (mCursor == null ){ |
mString += "不能从" + str + "读数据\n" ; |
return ; |
} |
mString += "第一列:" + mCursor.getColumnName( 0 ) + "\n" ; |
mString += "第二列:" + mCursor.getColumnName( 1 ) + "\n" ; |
mString += "第三列:" + mCursor.getColumnName( 2 ) + "\n" ; |
mString += "第四列:" + mCursor.getColumnName( 3 ) + "\n" ; |
mString += "列数:" + mCursor.getColumnCount() + "\n" ; |
mString += "行数:" + mCursor.getCount() + "\n" ; |
if (mCursor != null ) { |
while (mCursor.moveToNext()) { |
// 取得联系人名字 |
int nameFieldColumnIndex = mCursor.getColumnIndex( "name" ); |
mString += mCursor.getString(nameFieldColumnIndex)+ " " ; |
// 取得电话号码 |
int numberFieldColumnIndex = mCursor |
.getColumnIndex( "number" ); |
mString += mCursor.getString(numberFieldColumnIndex)+ " " ; |
// 取得邮箱 |
int emailsFieldColumnIndex = mCursor |
.getColumnIndex( "emails" ); |
mString += mCursor.getString(emailsFieldColumnIndex)+ " " ; |
// 取得id |
int idFieldColumnIndex = mCursor |
.getColumnIndex( "_id" ); |
mString += mCursor.getString(idFieldColumnIndex)+ "\n" ; |
} |
} |
mString += mCursor + "\n" ; |
mCursor.close(); |
} |
高级设计师
by: 由月君 发表于:2013-10-26 16:10:28 顶(1) | 踩(0) 回复
这个不错
回复评论