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();
}
分享到:
相关推荐
java jsonarray 踢重 去重操作
andriod Volley的HTTP网络通信,包含get、post请求,获取String/JsonObject/JsonArray数据(android客户端+java服务器端)
JSONArray需要的jar包
这是一个关于JSONArray实现的一个小实例,代码比较简单,目的在于理解JSONArray的实现
Android开发-Fragment JsonObject JsonArray 综合运用-AndroidStudio http://blog.csdn.net/iwanghang/article/details/52488420
JSONArray需要的jar包,包含以下: json-lib-2.4-jdk15.jar json-lib-2.4.jar ezmorph-1.0.6.jar commons-logging-1.1.1.jar commons-lang-2.6.jar commons-collections-3.2.1.jar commons-beanutils-1.9.2....
JSONObject、JSONArray需要的jar包,需要的可以直接联系
JSONArray解析包,JSONArray.fromObject使用,可以解析map,list等
JSONArray常用包.rar,非常实用的包包,请查收。
给出提前排序的数组,jsonArray中字段根据数组顺序重新排序。
如何生成JSON格式的数据 解析JSON格式的数据
JSONArray的使用 附带程序注释与输出
使用JSONArray.fromObject所需要的jar包,不使用的话会导致JSONArray.fromObject方法报错
JSONObject与JSONArray所需jar包 ===JSONObject与JSONArray所需jar包
JSONArray JSONObject所需JAR json-lib-2.4-jdk15.jar commons-beanutils-1.9.2.jar commons-collections-3.2.1.jar commons-lang-2.5.jar commons-logging-1.1.1.jar ezmorph-1.0.6.jar
android数据缓存(可设置时间):普通的字符串、JsonObject、JsonArray、Bitmap、Drawable、序列化的java对象,和 byte数据。
net.sf.json.JSONArray等JSON类所需要的jar包组合。包括JSONObject等
包含 json-lib-2.4-jdk15.jar , ezmorph-1.0.6.jar commons-logging-1.2.jar commons-lang-2.5.jar commons-collections-3.2.jar commons-beanutils-1.8.0.jar
一些常用的json包如:commons-logging-1.0.4.jar commons-lang-2.3.jar commons-collections-3.2.jar commons-beanutils-1.7.0.jar 等
该资源包含了一个使用gson解析并生成json的各种操作,分类清晰,简单易懂,一看就会。