I want to access an online MySQL database in order to retrieve and manipulate data. I read that the best way would be implementing an own web-service, which returns XML and then parse it in Android, is it right?
Does anybody have a basic tutorial?
2 に答える
Since you want to access a remote server which has your DB and other stuff. You basically have two options.
1 - ) Either directly access your server via sockets etc.
2 - ) Or create a web service which will connect your server to the outside. ( I.e : Android Client,iOs client etc.)
The best practice is to create a web service and then consume it in your Android application.
Check these for consuming XML in Android.
http://www.ibm.com/developerworks/opensource/library/x-android/
Check these for creating web services on server side. (Stack independent)
http://davidwalsh.name/web-service-php-mysql-xml-json (PHP)
http://www.roseindia.net/webservices/buildingsimplewebservice.shtml (Java)
And so on there are a lot of stacks to create web services.
Again, Webservice is the best approach. But you have to take decision based on the amount of the data being retrieved from the server and how often the transaction needs to be synchnorized with the server.
What Arvind was trying to explain you, incase if the volume of data is too large to download via webservice then you probably need to think of some middle tier that will convert he data to json and send it to your device. The reason, if you are transmitting the 1k of soap response over the air, for the same response, if you are transmitting thro json, it could be 100k or 200k or 300k depends. That way you can save the transmission cost over the net and turnaround time is quicker .