Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将EditText中的数据发布到web服务器中的外部数据库_Android_Database - Fatal编程技术网

Android 将EditText中的数据发布到web服务器中的外部数据库

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

我是android新手。我需要将EditText中的数据发布到服务器数据库表中。数据被发送到php页面。SQL查询在该页面中。请大家帮帮我。我不知道如何执行此操作。请看…

以下是将一些文本数据发送到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();
    }