HTTP
post

ANDROID HTTP POST

More than 1 year has passed since last update.
public void saveDni(String id, String dni) {     

HttpClient httpclient = new DefaultHttpClient();     
HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");      

try {         
    //Añade las variables a enviar por post         
    List<NameValuePair> postValues = new ArrayList<NameValuePair>(2);         
    postValues.add(new BasicNameValuePair("id", "000001"));         
    postValues.add(new BasicNameValuePair("dni", "23234345T"));         

    httppost.setEntity(new UrlEncodedFormEntity(postValues));          

    //Hace la petición         
    HttpResponse response = httpclient.execute(httppost);              
} 
catch (ClientProtocolException e) {         
    //TODO Auto-generated catch block     
} 
catch (IOException e) {         
    //TODO Auto-generated catch block     
} 
}