- //get system contacts
- Uri mContacts = People.CONTENT_URI;
- Cursor cur = managedQuery(mContacts, columns, // 要返回的数据字段
- null, // WHERE子句
- null, // WHERE 子句的参数
- null // Order-by子句
- );
- if (cur.moveToFirst()) {
- String name = null;
- String phoneNo = null;
- for(int i=0, count=0; i<cur.getCount(); i++)
- {
- name = cur.getString(cur.getColumnIndexOrThrow(People.NAME));
- phoneNo = cur.getString(cur.getColumnIndexOrThrow(People.NUMBER));
- if(null!=phoneNo && isPhoneNumberValid(phoneNo))
- {
- /*格式化手机号码*/
- names.add(count, name);
- phoneNos.add(count, phoneNo.replaceAll("-", ""));
- count++;
- }
- cur.moveToNext();
- }
- }//end get