如何通过服务器上的XML文件更新数据

时间:2011-07-06 10:23:31

标签: android

我正在解析XML文件中的数据并将其存储在数据库中。现在我想通过XML文件更新数据,我有一个更新数据的URL,但我没有办法在该URL上发送数据..

请帮助。

1 个答案:

答案 0 :(得分:1)

              List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4);
    nameValuePairs.add(new BasicNameValuePair("latitude", "00.11"));
    nameValuePairs.add(new BasicNameValuePair("longitude", "00.11"));
    String url = "http://10.15.66.101:8080/LocationServer/GetLocation";

          HttpClient httpClient = new DefaultHttpClient();

    HttpPost httpPost = new HttpPost(
            url);

    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

    // Execute HTTP Post Request
    HttpResponse response = httpClient.execute(httpPost);

    BusinessManager.getHandler().getLoggerUtilityObj().printMsg(
            "Posting data to server");
    // This is done to shutdown the previously open http connection
    httpClient.getConnectionManager().shutdown();