我是 android 新手。我需要将 EdiText 中的数据发布到服务器数据库表。数据被发送到 php 页面。SQL 查询在那个页面中。请大家帮帮我。我不知道该怎么做.pleaseee...
问问题
475 次
1 回答
0
这是将一些文本数据发送到 PHP 脚本的一个示例:
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("text", text));
nameValuePairs.add(new BasicNameValuePair("text2", text2)); //you can add as many you need
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://yourserver.com/script.php");
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch (Exception e) {
// TODO: handle exception
Log.e("log_tag", e.toString());
return false;
//Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
}
于 2012-05-02T08:13:57.747 回答