i want to send data from android application to local server (PHP) but it doesn't work this is my code (it is work with remote server ):
String path ="http://localhost/sd.php"; HttpClient client = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(client.getParams(), 100000);
HttpResponse response;
JSONObject json = new JSONObject();
try {
HttpPost post = new HttpPost(path);
json.put("im", 999);
json.put("cTime", 12);
Log.i("jason Object", json.toString());
post.setHeader("json", json.toString());
StringEntity se = new StringEntity(json.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/json"));
post.setEntity(se);
response = client.execute(post);
} catch (Exception e) {
Object n=e.getStackTrace();
Toast.makeText( getApplicationContext(),n.toString(),Toast.LENGTH_SHORT).show();
}
i thing the wrong in the address http://localhost/sd.php pleas help me to find a solution to this problem