Data Post to server

  • Replies:1
Rimpy
  • Forum posts: 17

Dec 6, 2011, 7:46:24 AM via Website

Hi,

I have problem of how is possible post data to server.I getting stuck with this issue last few days.
Please find any solution for that.I waiting of your positive response asap.

Thanks in advance,
Rimpy

Reply
Calvin Weiss
  • Forum posts: 7

Dec 6, 2011, 10:40:48 AM via Website

In android you can use NameValuePair to send data through post request

DefaultHttpClient hc=new DefaultHttpClient();
ResponseHandler <String> res=new BasicResponseHandler();
HttpPost postMethod=new HttpPost("http://192.168.1.123:8080/ab/wine");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("name", "sachin"));
nameValuePairs.add(new BasicNameValuePair("occupation", "player"));
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));
String response=hc.execute(postMethod,res);

Hire android application developer for android apps development

Reply