Android 将EditText中的数据发布到web服务器中的外部数据库
我是android新手。我需要将EditText中的数据发布到服务器数据库表中。数据被发送到php页面。SQL查询在该页面中。请大家帮帮我。我不知道如何执行此操作。请看…以下是将一些文本数据发送到php脚本的一个示例:Android 将EditText中的数据发布到web服务器中的外部数据库,android,database,Android,Database,我是android新手。我需要将EditText中的数据发布到服务器数据库表中。数据被发送到php页面。SQL查询在该页面中。请大家帮帮我。我不知道如何执行此操作。请看…以下是将一些文本数据发送到php脚本的一个示例: ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("text", text
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();
}