Reputation: 29
I am trying to connect to localhost/myfile.php
on my computer. The PHP file converts database data into JSON
which I want to parse after connecting. When I try to connect, I get
Target host must not be null, or set in parameters. scheme=null, host=null,
path=10.0.0.9/myfile.php
Any ideas?
public void getData(){
String result = "";
InputStream isr = null;
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("10.0.0.9/myfile.php");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
isr = entity.getContent();
}
catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
resultView.setText("Couldnt connect to database" + e);
Upvotes: 0
Views: 6000
Reputation: 55380
Looks like you're missing the URI scheme.
Try with new HttpPost("http://10.0.0.9/myfile.php");
Upvotes: 1