[英]How do I connect my Android app to a MySQL database on a laptop, PC, or server?
How do I connect an Android device to a PC, laptop, or server? 如何将Android设备连接到PC,笔记本电脑或服务器?
I have finished my Android program using Eclipse. 我已经使用Eclipse完成了Android程序。 I also use a client - server system (I'm using MySQL, not SQLite, to store my database)
我还使用客户端服务器系统(我使用的是MySQL,而不是SQLite,用于存储数据库)
when I run my program in emulator, it runs nicely (using CustomHTTPClient with address to connect MySQL is http://10.0.2.2/android/blablabla.php
) 当我在模拟器中运行程序时,它运行得很好(使用具有地址的MySQL的CustomHTTPClient连接MySQL是
http://10.0.2.2/android/blablabla.php
)
But, will it be the same code to connect to a MySQL database when I deploy the app onto a real device? 但是,将应用程序部署到真实设备上时,连接到MySQL数据库是否会使用相同的代码? if no, what should I do to connect the device to my database(MySQL) in my PC/Laptop/Server?
如果不是,我该怎么做才能将设备连接到PC /笔记本电脑/服务器中的数据库(MySQL)? How should I change the code?
我应该如何更改代码?
I don't use Bluetooth because the distance is too short. 我不使用蓝牙,因为距离太短。
You could use your computers IP address. 您可以使用计算机的IP地址。 Find this by tpying 'ipconfig' into the command prompt.
通过在命令提示符下键入“ ipconfig”来查找此内容。 Look for and use your IPv4 address, it should be similar to:
查找并使用您的IPv4地址,该地址应类似于:
192.168.0.XX/android/blablabla.php
You just have to make sure that the Android phone is connected to the same network the PC/Server is in and replace 10.0.2.2
with the ip address of the Server. 您只需要确保Android手机连接到PC /服务器所在的同一网络,然后用
10.0.2.2
的IP地址替换10.0.2.2
。 I assume that you don't have a domain. 我假设您没有域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.