user1167473
user1167473

Reputation: 21

External Database and Android application

I am creating an android application which records soccer scores.

I have an external mysql database created on my own host.

How do i retrieve the data from the database in order to display it in my application?

Thanks in advance!

Upvotes: 0

Views: 1838

Answers (2)

AbSoLution8
AbSoLution8

Reputation: 1213

If you also want to retrive the information to be used offline, you can create an empty database locally, and update it by passing SQL statements. This is not the most efficient way to do it, but it worked for me since I am not working with a huge db.

Otherwise, use HTTP connection connecting to your remote host and pass the result via JSON object.

Upvotes: 0

kosa
kosa

Reputation: 66637

You need to write a service hosted on your database using either php or some other language you are comfortable which exposes data as XML/JSON.

Android has HTTPURLConnection capability,using which you can query your service by passing the parameters. Your service queries database and consturcts data either as XML or JSON using libraries and returns to app.

Your app need to parse the response (if XML, using SAX/DOM or someother APIs, if JSON using Android in-buit json parser) and display. Here is an example on how to do.

Upvotes: 3

Related Questions