Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
    
did you setup your localhost with required DB and php? –  Nizam Jun 10 '13 at 16:08
    
yes I already did –  Anthony Pangestu Jun 10 '13 at 17:14
    
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

1 Answer 1

Try this out...

String loginURL = "http://10.0.2.2/android_login_api/";
share|improve this answer
    
Not working also –  Anthony Pangestu Jun 11 '13 at 15:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.