0

I am new to android and java. I am trying to develop a test app which gets data stored in local database. I am using WAMPP. In emulator I can access it perfectly, but when I try to access it in my physical device (Micromax A311) I get java.io.FileNotFoundException. I have seen many questions asked for this question, but none worked for me.

In my AndroidManifesti have added following code

<uses-permission android:name="android.permission.INTERNET"/>

Url

String url="http://192.168.0.104/selectQuery.php";

which is my IP4 (Wireless LAN adapter Wi-Fi) address.

I have tried it with

http://10.0.2.2/....
/10.0.2.2:80/....
/192.168.0.104:80/

I can access data in browser saved in my database using

/192.168.0.104/ and /192.168.0.104:80/

I am connected physical device via USB to laptop. In my tethering setting I turned USB tethering on.

I am connected with same WiFi which is connected to my laptop.

My proxy setting of laptop is also off.

Can anyone help me to get out of this problem.. I am struck in this from past few days..

Thank you

  • localhost, means the current running machine. In emulator it is your pc. at your android device it is the device itselfe, where no WAMPP is running.https://en.wikipedia.org/wiki/Localhost – Fusselchen Mar 04 '17 at 17:41
  • Okay!!!! How do i access database from android device? – Thomsheer Ahamed Mar 05 '17 at 09:14
  • http://192.168.0.104/selectQuery.php should work, if you are not blocking remote access (firewall, apache settings) to your WAMPP. Try it from a remote device (maybe a browser in your phone) that you can access this url. To verify if its a problem of your app or your setup. The database connection is done by your php script, so there shouldn't be any changes necessary – Fusselchen Mar 06 '17 at 10:21

2 Answers2

0

If selectQuery.php file is in a folder your url is like:

String url ="http://192.168.0.104/name_folder/selectQuery.php";

So if have ./myFolder/selectQuery.php the url is:

String url = "http://192.168.0.104/myFolder/selectQuery.php";
Simone Boccato
  • 199
  • 1
  • 14
0

Thanks for your reply... I found a solution myself. I downloaded https://ngrok.com/download, then used its CMD and copy pasted

 ngrok http -bind-tls=false site.dev:80

which i found in https://ngrok.com/docs#bind-tls under Tunneling only HTTP or HTTPS. Then I used forwarding address in my url string.

It worked Fine.. I am happy now..