I'm trying to develop an android app that calls a php file to query and pull data from a database. The URL is accesible on my mobile phone on the web browser, but I can't seem to call it from my java code below. Could anyone assist me in calling my PHP file from my Java code.
URL url = new URL("http://10.0.3.2/MYCODE/app/login.php");
String urlParams = "name="+name+"&password="+password;
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setDoOutput(true);
OutputStream os = httpURLConnection.getOutputStream();
os.write(urlParams.getBytes());
os.flush();
os.close();
InputStream is = httpURLConnection.getInputStream();
while((tmp=is.read())!=-1){
data+= (char)tmp;
}
is.close();
httpURLConnection.disconnect();
I get the following error: java.io.FileNotFoundException:
I'm using the POST method because it's more secure.