Here you can find the source of getContentFromProvider( ContentResolver contentResolver, Uri uri, String[] valueTypes)
public static JSONArray getContentFromProvider( ContentResolver contentResolver, Uri uri, String[] valueTypes)
//package com.java2s; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; public class Main { public static JSONArray getContentFromProvider( ContentResolver contentResolver, Uri uri, String[] valueTypes) { Cursor cursor = contentResolver.query(uri, null, null, null, null); JSONArray array = new JSONArray(); if (cursor != null) { while (cursor.moveToNext()) { try { JSONObject obj = new JSONObject(); for (int i = 0; i < valueTypes.length; i++) { String value = cursor.getString(cursor .getColumnIndex(valueTypes[i])); obj.put(valueTypes[i], value); }//from w ww .j av a 2 s.c o m array.put(obj); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return array; } }