• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps application crashes

jammy992

Lurker
Sep 14, 2012
9
0
im writing my first application connecting with my website. But it crashes when i use this code. anyone can help me?
Code:
            //Create a new HttpClient and Post Header
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("httpwwwwebsitecom/android/save.php");
      
             try {
                 // Add your data
                 List <NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                 nameValuePairs.add(new BasicNameValuePair("id", "12345"));
                 nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
                 httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                 
                 // Execute HTTP Post Request
                 HttpResponse response = httpclient.execute(httppost);
                
             } catch (ClientProtocolException e) {
                 //e.printStackTrace();
                 // TODO Auto-generated catch block
             } catch (IOException e) {
                 //e.printStackTrace();
                 // TODO Auto-generated catch block
             }
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones