Code example for UrlEncodedFormEntity

0
 
	public String DoPost(String url, List<NameValuePair> params)throws IOException {
		// Create a new HttpClient and Post Header 
		HttpClient httpclient = new DefaultHttpClient();
		HttpPost httppost = new HttpPost(url);
		httppost.setEntity(new UrlEncodedFormEntity(params));
		// Execute HTTP Post Request 
		HttpResponse response = httpclient.execute(httppost);
		String result = convertStreamToString(response.getEntity().getContent());
		return result;
	} 
	public String DoGet(String url, List<NameValuePair> params)throws IOException {
		// Create a new HttpClient and Get Header 
		HttpClient httpclient = new DefaultHttpClient();
		if(params!=null){
			url.concat("?").concat(URLEncodedUtils.format(params,"UTF-8"));
		} 
		 
		HttpGet httpget = new HttpGet(url);
		// Execute HTTP Post Request 
		HttpResponse response = httpclient.execute(httpget);