android1.5获得所有联系人ID,人名,默认移动电话号码,并生成 JSONArray数据
private String getContacts(Object parameters) { JSONArray peopleJSON = new JSONArray(); Cursor tempContactsCursor = AndroidBaseActivity.self .getContentResolver().query(Contacts.People.CONTENT_URI, null, null, null, null); if (tempContactsCursor.moveToFirst()) { do { JSONObject jsonPeopleNumbers = new JSONObject(); // 获得联系人的ID号 int idColumn = tempContactsCursor .getColumnIndex(Contacts.People._ID); int peopleNameIndex = tempContactsCursor .getColumnIndex(Contacts.People.DISPLAY_NAME); int mobileNumberIndex = tempContactsCursor .getColumnIndex(Contacts.Phones.NUMBER); String id = tempContactsCursor.getString(idColumn); String name = tempContactsCursor.getString(peopleNameIndex); try { jsonPeopleNumbers.put("mobile", tempContactsCursor .getString(mobileNumberIndex)); jsonPeopleNumbers.put("name", name); jsonPeopleNumbers.put("id", id); } catch (JSONException e) { e.printStackTrace(); } peopleJSON.put(jsonPeopleNumbers); } while (tempContactsCursor.moveToNext()); tempContactsCursor.close(); } return peopleJSON.toString(); }
相关推荐
somebodyoneday 2020-06-15
adonislu 2020-06-02
baijinswpu 2020-02-19
adonislu 2020-02-14
83163452 2020-01-28
adonislu 2020-01-10
baijinswpu 2020-01-01
adonislu 2019-12-31
baijinswpu 2019-12-28
xufankang 2019-12-19
somebodyoneday 2019-12-07
abcx 2015-05-25
somebodyoneday 2019-10-30
newthon 2019-10-21
ZCMUCZX 2016-04-14
iovaaron 2015-04-10
Dolphinsz 2016-04-25