开发者

How exactly do i build an app that syncs information from a locally stored database to the cloud?

So I'm familiar with the basics of android development, but I was confused about some things. I have a locally stored database on the phone. How do I get it to sync to some server on the cloud? I mean, what's the whole process, how do I go about writing code for that? Even some tutorials/expla开发者_如何学Pythonnations/guides would be helpful.

Thanks.


Your question is extremely general in nature so it's hard to know exactly what you are looking for but I'll attempt to point you in the right direction.

Google has a demo application called JumpNote which demonstrates an Android application that syncs with a Google Web Toolkit (GWT) application running on Google App Engine (GAE). Using this as an starting point would be an extremely good idea. Assuming your application is low traffic the GAE hosting would be free. GWT is also a fantastic way to write really rich web applications. Since GWT is Java, this would allow you to share classes between your Android app and web app (e.g., POJOs) saving time and reducing duplication.

The high-level view of this synchronization is basically having a web application hosted somewhere that exposes an API and the Android application making calls to that API in order to update the remote data to reflect any local changes.


The generic way of doing this would be to include a last-modified field in your local and remote tables.

You then request rows from the server where the last-modified is newer than the latest value from your previous download. Similarly, you upload any local rows where the last-modified is newer than the last upload. Conflict resolution is something you will need to address, and is sometimes handled by per-field-on-row last-modified times, instead of per-row.

You probably want to do this in a service, (or by writing a sync provider) so that the updates happen without explicit user interaction.

Hope this helps,

Phil Lello

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜