How does Android, PHP, SQL, JSON, and Remote Databases work together?
As I’ve mentioned, our Android app and a remote MySQL database can’t communicate with each other directly without it being an incredibly tedious process. It would be like a Chinese person trying to talk to someone from Iceland. We don’t want to play charades if we don’t have to, so instead, we will get an interpreter. This interpreter will be PHP. PHP will do all of the talking for us. For example, if we want to create a new user for our application from our Android device, we will want our application to have some input fields, such as username, password, favorite kind of cheese, etc. When the user fills out this information and hits submit, we will pass the information to our PHP web service. The web service will connect to the MySQL Database, and find the “Users” table and insert a new row into the MySQL database with the information that was sent from our Android device. Once our row is created, we will have our webservice display some JSON data that will tell us whether we entered the data successfully or not. Lastly, our Android device will parse this JSON data and display a “Success” message, or a “Failure, please try again” message.
The process in visual form would look like this:
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。