android httppost mysql没有双重输入

时间:2014-07-18 10:37:05

标签: android mysql

我正在使用HttpPost通过php将arraylist值插入mysql但是我的mysql中有双重输入我在底部提到了我的代码

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://");
ResponseHandler<String> responseHandler=new BasicResponseHandler();

try {

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new BasicNameValuePair("a", a.getText().toString()));
    nameValuePairs.add(new BasicNameValuePair("b", b.getText().toString()));
    nameValuePairs.add(new BasicNameValuePair("c", c.getText().toString()));
    nameValuePairs.add(new BasicNameValuePair("d", d.getText().toString()));
    nameValuePairs.add(new BasicNameValuePair("e", e.getText().toString()));
    nameValuePairs.add(new BasicNameValuePair("f", f));
    nameValuePairs.add(new BasicNameValuePair("g", g));

    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

    HttpResponse response = httpclient.execute(httppost);

    String responseBody = httpclient.execute(httppost, responseHandler);

    Toast.makeText(getApplicationContext(), responseBody, Toast.LENGTH_SHORT).show();

    Log.d("a", responseBody );

1 个答案:

答案 0 :(得分:0)

您似乎正在执行httppost两次。尝试删除该行

HttpResponse response = httpclient.execute(httppost);

据我所知,你没有使用response