how to add parameters in android http post? -


Friends,

I have been trying to upload the file to the php server using the following tutorials

I do not know how to add parameters such as

userid = "12312"; Sessionid = "234"

How does anyone guide me to achieve this?

Any help would be appreciated.

On the Internet you will find many examples

How to add parameters? You should have something like this.

  // Add your data list & lt; NameValuePair & gt; NameValuePairs = New ArrayList & lt; NameValuePair & gt; (2); NameValuePairs.add (New BasicNameValuePair ("userid", "12312"); NameValuePairs.add (New BasicNameValuePair ("sessionid", "234"); Httppost.setEntity (new UrlEncodedFormEntity (nameValuePairs)); Public Zero PostData () {// A new HTTP client and post header HTTP client httpclient = new DefaultHttpClient (); Http post httppost = new HTTP post ("http://www.yoursite.com/myexample.php"); Try {// Add Your Data List & lt; NameValuePair & gt; NameValuePairs = New ArrayList & lt; NameValuePair & gt; (2); NameValuePairs.add (new BasicNameValuePair ("id", "12345"); NameValuePairs.add (New BasicNameValuePair ("stringdata", "stackoverflow.com is cool!")); Httppost.setEntity (new UrlEncodedFormEntity (nameValuePairs)); // Execute HTTP Post Request HTTP Response Response = httpclient.execute (httppost); } Catch (Protocol Epson E) {// To-Auto-Generated Catch Block} Catch (IOE Execution E) {// Tudo Auto-Generated Cache Block}}  

Comments