I am very new to Android programming. I was trying to access database connection for Android via SQL Server and PHP (Server side).
Now , I am able to connect to do a work on the local machine via Emulator using the locahost.
But I am not able to do that connection while connecting the Android tablet via USB cable to check the application on actual Android device.
Is there any way, I can access localhost on my Android tablet via USB cable. Just as how it work with 10.0.2.2 along with the Emulator.
Any help or comments would be great !!!
No you cannot. Connecting with USB cable to your machine does not put your android device on the computer’s network.
If your system (the system hosting the localhost server) is on a network, try connecting the device on to the network using WIFI.
In one HTC phone, i saw the option Reverse Tethering when connected to the system. If your device supports reverse tethering then you can connect your android device using this mode. This will enable the device to be on the same network as your computer.
FYI, when doing this, if you try connecting to localhost it will not work, you have to specify the IP address of your system.