Need to append a string in DoPost method using andoid

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Need to append a string in DoPost method using andoid

Postby suhabb » Mon Jan 04, 2010 5:43 am

I need to append a string to the URL in doPost method and sent it to server.

public void postData(){

// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://URL:8080/ActionServlet");

try {
// Add your data
// List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
// nameValuePairs.add(new BasicNameValuePair("mydata", "Mek Mek"));
String s="c1cf502a9441c48e7ee98f32d1d64413:c1cf502a9441c48e7ee98f32d1d64413";
httppost.setEntity(new StringEntity(s)); //i need to append the string something like this and send it to the srver.

BasicHttpResponse response = (BasicHttpResponse) httpclient

Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);

InputStream is = response.getEntity().getContent();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(20);

int current = 0;
while((current = != -1){

Convert the Bytes read to a String.
text = new String(baf.toByteArray());

} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
Posts: 2
Joined: Wed Dec 23, 2009 10:56 am


Postby jwei512 » Mon Jan 04, 2010 10:20 am

Try reading this? ... post-call/

This is my little code snippet on how to do POST calls with params. Maybe you'll find it useful.
- jwei
Examples, Code, and Tutorials
Senior Developer
Senior Developer
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA


Return to Networking & Database Problems

Who is online

Users browsing this forum: Google [Bot] and 4 guests