I m trying to delete a row having id 109 from mySQL database on a web server using my android device (through web services). Web service is working fine with specific url and id when I check on browser. But when I execute my android code, i got following exception in Logcat
android.os.NetworkOnMainThreadException
by trying this following code
try{
String url = "http://example.com/user/delete";
String u_id = 109;
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("id",u_id));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost); //problem is in this line but I don't know what the problem actually is
HttpEntity entity = response.getEntity();
Log.e("pass 1", "connection success ");
}
catch(Exception e){
Log.e("Fail 1", e.toString());
}
I didn't understand what this exception means and how to solve this problem
Great thanks for your valuable time and help in advance