"Untitled Post" - Views: 236 · Hits: 236 - Type: Unlisted

try 
		{

			String toSearchDb = toSearch;

			JSONObject json = new JSONObject();

			json.put("searchText", toSearchDb);

			HttpParams httpParams = new BasicHttpParams();
			HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
			HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
			HttpClient client = new DefaultHttpClient(httpParams);

			String url = "http://www.mydomian.com/data/data.php"; 

			HttpPost request = new HttpPost(url);
			request.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
			request.setHeader("json", json.toString());
			HttpResponse response = client.execute(request);
			HttpEntity entity = response.getEntity();


			if (entity != null) 
			{

				Log.e("Search","inside entity not null");

				InputStream instream = entity.getContent();

				String resultDb = StreamToString.convertStreamToString(instream);
				//	Log.e("Read from server", result);
				//	Toast.makeText(this,  result, Toast.LENGTH_LONG).show();
			}
			Log.e("TRACE", "UPDATE 3");

		}

		catch (Throwable t) 
		{
			Log.e("TRACE", "UPDATE 4 EXCPTION "+t);
			Toast.makeText(this, "Request failed: " + t.toString(), Toast.LENGTH_LONG).show();
			Log.e("Read from server", t.toString());
		}
	}