-1

I created an android app that fetch data from mysql database using localhost wamp server, but the problem is there is no data when I run the app and there is no any error in log,

and when I run my php file (test.php) using the browser it shows data

http://127.0.0.1:81/Test/test.php

here is the code where I added the php url:

  private static final String URL_PRODUCTS = "http://127.0.0.1:81/MyApi/Api.php";

any help will be appreciated.

  • 1
    if you run application in to your device then i should be having connected to your Local PC or with that WIFI – ND1010_ Dec 02 '17 at 11:27
  • Have you tried this? [https://stackoverflow.com/questions/5528850/how-to-connect-localhost-in-android-emulator](https://stackoverflow.com/questions/5528850/how-to-connect-localhost-in-android-emulator) – szamani20 Dec 02 '17 at 11:27
  • @ND1010 I didn't tested it on my phone, I used emulator. – azater 2000 Dec 02 '17 at 11:53
  • ok compare your URL for both @ PHP side and @ android side – ND1010_ Dec 02 '17 at 11:55

1 Answers1

0

I solved the issue by using this IP: 10.0.2.2

thanks to szamani20 and this post:

how to connect localhost in android emulator?