I was brainstorming how I should handle this. This is how the application is going to work:
- User enters multiple pieces of data into app
- App stores data into SQLite database
- User hits SYNC button and app will pass all new/updated/deleted info to site PHP and update MYSQL.
I was thinking I can do a loop where it sends (and receive) one row at a time to mysql or I can use a string builder to build a XML, and pass (and receive) the XML string to PHP to process. The xml will have tag data specifying if the element is to be added, deleted or updated.
I figure the XML is a better option, but I’m coming here for opinions how I should push multiple rows to be added/deleted or updated to my MYSQL because I feel there’s probably a more efficient/easier way of doing this.
Thanks!
–UPDATE–
Here’s some helpful links I found of JSONArrays for those seeking similar information as I am about Android SQLite to PHP MYSQL.
- Nice tutorial about JSONArrays in PHP: http://webhole.net/2009/08/31/how-to-read-json-data-with-php/
- Another tutorial about JSONArrays in Java: http://www.androidcompetencycenter.com/2009/10/json-parsing-in-android/
Ah, opinions. Painful things though: everyone has one and everyone thinks their opinion is better than the next persons’.
I’ve implemented a system that is pretty much identical: I used JSON for it though. There is no intrinsic issue with using XML: whatever translation layer you are comfortable with is probably fine. JSON was (for me) a bit more compact than XML, required less code on both sides (
json_decodeis your friend) and seemed to me to be an easier row to hoe than using XML. However PHP’s simplexml would probably work fine as well.If you’re doing this from scratch you might want to look at one of the systems with automatic data syncing like Mobile Couchbase (see http://www.couchbase.com/products-and-services/mobile-couchbase): would require a fair bit more tooling and a bigger server/client resource footprint but might get you there faster.