Parmendra Singh
Parmendra Singh

Reputation: 1035

Sending integer value using DefaultHttpClient

I am using DefaultHttpClient to send data to web... To send data m using following code block:

nameValuePairs.add(new BasicNameValuePair(name, value));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

but namevaluepairs only take string.. I need to send integer value with this.

Please guide.. Thanks in advance.

Upvotes: 0

Views: 2745

Answers (1)

Shlublu
Shlublu

Reputation: 11027

Use Integer.toString(integerValue). For example:

nameValuePairs.add(new BasicNameValuePair(name, Integer.toString(5)));

Edit, further to the comments below:
And for a float you can use:

nameValuePairs.add(new BasicNameValuePair(name, Float.toString(10.82522f)));

Upvotes: 1

Related Questions