开发者

Android remote MySQL operations using a web service with php

I read some nice articles about how to connect to a remote MySQL database via Android.

Found some really interesting links here and here.

So the common way for getting data seems to be using some kind of webservice (interface, in this case a php script) which queries the db and renders the result in JSON (or XML) format. Then its possible to parse this output with the android JSON_Object implementation. So far so good.

Receiving data from the database and showing it up in a android listview was done in about minutes.

But what is the best practice for writing (inserting) data into tables?

Should a webservice be used here too? (or rather direct mysql conn)

What is开发者_运维问答 the best method to push data to a webservice? (for ex. to insert a new entity in a database) and which format should be used?

In this case I do not use any html forms or anything to post the parameters. So how to post these parameters to the php script? (from within the android app!) Of course this operation should be secure as well. Implementing a data manipulation machanism is bit more risky (in order to keep the db persistant)

I think, that many apps use some kind of DB, to synchronize data (ex: highscores). So there should be a best practise for that.


I would recommend keeping anything database-specific hidden behind a web service.

If you build a dependency on MySQL into your application and later find that you need to change databases, the entire installed base has to be cut over. Think about the logistics of accomplishing that for a few minutes and you'll start to realize it's a nightmare.


Premiumsoft's Navicat for MySQL comes with a HTTP tunnel (PHP script) you might be able to use. It basically provides a method for doing anything to a MySQL database over HTTP.

I'd just make sure there are no licensing issues if you plan to distribute your app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜