4

I'm trying to make an SQLite database on the first run of a program, with a single table containing 7 rows, which is intended to match up with a table on a MySQL database on a remote server. So my thoughts are:

(1) On first application run only, create the database, the table, and the number of rows with the desired entries.

(2) On all runs (including the first one) poll a remote MySQL database (over PHP) that contains a table with a timestamp column, and if the timestamp conditions are met (i.e. a new entry has been placed in the database), all entries after that will be added into the SQLite database on the Android phone.

If someone can point me in the right direction or give me some basic code for any aspects of this, that'd be great - thanks.

0

2 Answers 2

3

Well, there aren't any magic bullets to sync android with a database in the cloud. Since you are only dealing with 7 rows, I would use an AsyncTask and http client to send a get request to your php page and return the 7 rows and timestamps as a json document. Then I would query your local sqlite db and get the rows and timestamps out of there. You can then iterate through the 7 rows and update the sqlite as required. That would be pretty easy.

If you are willing to use a different database, you might want to look into couchDB, they have an android client (in beta) that will sync with a couchDB in the cloud. You could create a couchDB at cloudant.com for free. Go google "couchbase android" if you wish to pursue this method.

Sign up to request clarification or add additional context in comments.

Comments

0

Agree with nickfox that if it's just 7 rows, something simple like AsyncTask would be a good way to go.

However, if you're thinking that there may be more data to synchronize and you're looking for options, I'll add another one: the Oracle Database. You can use the Oracle Database Mobile Server to synchronize data between a SQLite database and an Oracle Database running elsewhere.

This gives you the best of both worlds -- the light weight, easy to use and deploy SQLite database and application on the Android device, the enterprise-class fully functional, scalable, high performance Oracle Database running within the corporation or on the cloud and the Mobile Server in between to ensure that the data stays in sync.

Good luck in your search & implementation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.