I have an android app that maintains a local SQLite database of different geographic locations.
Now I would like to connect that database to the "cloud" to accomplish the following:
an initial download of everything, when the app is first installed (or on request)
new locations that have been added locally should be uploaded to the cloud (automatically)
the online database should be checked occasionally for new online entries, and downloaded to the local database.
I have a number of problems in accomplishing this.
The first is simply how to do it. I think it involves contentProviders and syncProviders, but I'm not exactly sure how. Do I need to duplicate my SQLite database in a contentProvider, or have I made a mistake in the underlying design to use a database directly, instead of through a custom content Provider?
Secondly, the location records cannot simply be copied up and down from the online database, since they will have conflicting ID numbers. I have several relational tables, such as "tags" which relate a tag-id to a location-id. My tag-ids will not necessarily match another users tag-ids. Same with location ids. So there will need to be some logic involved in the transfer. Where / how should this be properly handled? Is that the role of a contentResolver? (not sure what that is really)
Thirdly, what happens in the case where 2 users add the same location at the same time (perhaps with differing descriptions and details)? Is there a best-practice for merging these records?
Finally, what is the simplest way to build / host the online component? This part is all new to me. Can I just put the master database in a public dropbox folder, or do I need to build a custom php web-app from scratch? Or is there a pre-packaged solution that would make this part easier?