0
下面的代碼沒有返回....空白。我正試圖插入一個記錄到數據庫。Android putJSON沒有返回任何東西
public String inserComment(String url, String commentby, String commenton, String commenttext, String taskid)
{
String result = null;
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("CommentBy", commentby);
jsonObject.put("CommentOn", commenton);
jsonObject.put("CommentText", commenttext);
jsonObject.put("TaskID", taskid);
result = HttpHelper.postJSONforStringResult(url, jsonObject);
} catch (JSONException e) {
Log.e("DataUploader", "JSONException:" + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Log.e("DataUploader", "IOException:" + e.getMessage());
e.printStackTrace();
}
return result;
}
public static String postJSONforStringResult(String url, JSONObject json)
throws ClientProtocolException, IOException {
HttpResponse response = postJSON(url, json);
int statusCode = response.getStatusLine().getStatusCode();
String result = (statusCode == 201 || statusCode == 200) ? EntityUtils.toString(response.getEntity()) : "StatusCode=" + statusCode;
return result;
}
我不知道爲什麼indetation今天不工作。對此很抱歉。