user1589243
user1589243

Reputation: 1

What is the easiest way to update data on my android application from the web

What I want to do is figure out a way to retrieve new data from the web without having to update the app from the marketplace every time new data is added. The data would retrieve a list of "title", "description", and "website url". For example:

"title1", "description 1", "url1"
"title2", "description 2", "url2"
"title3", "description 3", "url3"
"title4", "description 4", "url4"
"title5", "description 5", "url5"
"title6", "description 6", "url6"

I want this to be secure and efficient.

I was thinking about possibly having a php page that connects to a mySQL database that has 4 columns (id, title, description, url) then the app can go to the php page such as http://www.website.com/database.php?getData&id=1 where "1" is the id of the row in the database. So http://www.website.com/database.php?getData&id=1 would display this string in the php page title1*description1*url1. The android app then would split the string from "*" to save the title, description, and url in an array. And "http://www.website.com/database.php?getData&id=2" would do the same but for the second row in the database.

Now I'm not sure if this is efficient. I was wondering what would be the best way to do this. I hope I made sense.

Upvotes: 0

Views: 220

Answers (1)

Nikola Despotoski
Nikola Despotoski

Reputation: 50588

Write php script that will query your database. Convert each row of the result into JSON format, echo it, collect the response JSON from your application, use some JSON libraries to manipulate the JSON output.

All you need is:

  1. php script - for querying your database (server side)

  2. Asynchronous approach from the client, use your own async implementation or use AsyncTask or Service

  3. Use JSON libraries (Google for them) to convert the JSON output to JSON objects for easier manipulation. Each database column will be presented as key in the JSON object.

  4. Display the data per your needs.

Cheers, I guess this gave you the glimpse.

Upvotes: 2

Related Questions