This is the code:
public boolean add(){
HttpClient cliente;
List<NameValuePair> lista;
HttpPost post;
cliente = new DefaultHttpClient();
post = new HttpPost("http://pruebamysqlandroid.esy.es/conexion/conexion.php");
lista = new ArrayList<NameValuePair>(3);
lista.add(new BasicNameValuePair("name", contactname.getText().toString()));
lista.add(new BasicNameValuePair("numbretlf", tlf.getText().toString()));
lista.add(new BasicNameValuePair("email", email.getText().toString()));
try{
post.setEntity(new UrlEncodedFormEntity(lista));
cliente.execute(post);//here is the error
return true;
}catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
When i try to add the contact to the server an error dont let me did help me please
The error is :
android.os.NetworkOnMainThreadException