tags:

views:

19

answers:

1

I have been working on this little music player for a while and I have been stuck for quite a couple of days in creating a now-playing list. I was thinking about storing it inside the database back end. Well, I have a remote interface and what I would like to do is that I would like to query and retrieve data from the database, from that remote interface. Any one would care to shed some lights?

A: 

Usually, the best way to do so is creating a REST API in the remote side. As you don't provide too much info let me suppose the remote database lives on a MySQL server and that you have PHP on that remote server too. In that case, you can write a PHP script that reads the database and returns a JSON response containing the data you want. Then, from your android App you just have to query that script and parse what you get.

This has too many advantages:

  • You can easily parse the response using the built-in JSON package (org.json)
  • Let's say you want to create an iPhone version of your app. Then, you just have to reuse the JSON resource you created.
Cristian