データベース検索結果をJSONで文字列にパッケージ


/**
 * @param mCursor           
 * @param col      
 * @return JSONArray(  , value)
 * @throws JSONException
 */
private JSONArray handlejson(Cursor mCursor, int col) throws JSONException{
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
if(mCursor == null){
return null;
}
while(mCursor.moveToNext()){
for(int i=0; i<col; i++){
jsonObject = new JSONObject();
for(int j=0; j<col; j++){
jsonObject.put(mCursor.getColumnName(j), mCursor.getString(j));
}
}
jsonArray.put(jsonObject);
}
return jsonArray;
}