我正在尝试连接到计算机上的localhost/myfile.php
。 PHP文件将数据库数据转换为JSON
,我想在连接后解析它。当我尝试连接时,我得到了
Target host must not be null, or set in parameters. scheme=null, host=null,
path=10.0.0.9/myfile.php
有什么想法吗?
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);
答案 0 :(得分:1)
看起来你错过了URI方案。
尝试使用new HttpPost("http://10.0.0.9/myfile.php");