【发布时间】:2014-07-31 15:29:33
【问题描述】:
我想在 Android 上执行HttpPost 来更新数据库中的单行。我不需要任何响应、验证等。所以我试图简化我的代码,因为我认为我所拥有的可能是多余的。
这就是我所拥有的:
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url_select);
httpPost.setEntity(new UrlEncodedFormEntity(param));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
httpEntity.getContent();
} catch (Exception e) {
e.printStackTrace();
}
我需要所有这些吗?看来我只能拥有了
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url_select);
httpPost.setEntity(new UrlEncodedFormEntity(param));
httpClient.execute(httpPost);
} catch (Exception e) {
e.printStackTrace();
}
这是正确的吗?
【问题讨论】:
-
没有理由不工作