I would like to just read on an android device some date i have loaded on a mysql database on a physical server. The database and the php script to extract the data are ok. The problem is the android coding side.
public class MainActivity extends Activity {
public HttpResponse response;
public String str;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("/*phpAddressIsCorrect*/");
try {
response = httpclient.execute(httppost);
}
catch(IOException e) {
e.printStackTrace();
}
try {
str = EntityUtils.toString(response.getEntity());
} catch(IOException e){
e.printStackTrace();
}
Toast.makeText(getBaseContext(), str, Toast.LENGTH_LONG).show();
}
}
The main.xml
is just a RelativeLayout
.
With android permission of internet, the apps crashes on loading. I suppose that's because of IOException, isn't it?