Code example for ConnectException

	 * @throws ConnectException 
	private static String getXML(Context context, String url, List<NameValuePair> postVariables)
			throws ConnectException { 
		if (!checkInternetConnection(context)) {
			throw new ConnectException("Connection Not available");
		String line = null;
		try { 
			DefaultHttpClient httpClient = new DefaultHttpClient();
			HttpPost httpPost = new HttpPost(url);
			httpPost.setEntity(new UrlEncodedFormEntity(postVariables));
			HttpResponse httpResponse = httpClient.execute(httpPost);
			HttpEntity httpEntity = httpResponse.getEntity();
			line = EntityUtils.toString(httpEntity);
		} catch (UnsupportedEncodingException e) {
			line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
		} catch (MalformedURLException e) {
Stop searching for code, let great code find you!  Add Codota to your java IDE