I urgently and desperately need help.
I want to connect my Android application to a local database with
private static String loginURL = "localhost/android_login_api/";
private static String registerURL = "localhost/android_login_api/";
public JSONObject loginUser(String email, String password){
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("tag", login_tag));
params.add(new BasicNameValuePair("email", email));
params.add(new BasicNameValuePair("password", password));
JSONObject json = jsonParser.getJSONFromUrl(loginURL, params);
// return json
Log.e("JSON", json.toString());
return json;
}
It doesn't work nor give any JSON reply.
But when I changed it into my friend's hosting:
private static String loginURL = "http://novalekaherdinata.cu.cc/android_login_api/";
private static String registerURL = "http://novalekaherdinata.cu.cc/android_login_api/";
It works fine.
Any idea why that happens? I cannot use my friend's hosting, since I need to present it in localhost. Thanks in advance
localhost
in this case will be the Android device itself. you need to use the IP Address of your development machine. – David M Jun 10 '13 at 17:39