Android应用程序脱机模式,与远方的本地数据库SQLite数据库同步 [英] android application offline mode, local sqlite database synchronisation with distant database

查看:204
本文介绍了Android应用程序脱机模式,与远方的本地数据库SQLite数据库同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 PostgreSQL数据库这是由通过Web服务的android应用操作。
我想知道是什么使一个离线模式作为我的应用程序的最佳方式。

I have a postgreSql database which is manipulated by an android application via Web Services. I'd like to know what is the best way to make an offline mode for my application.

我的第一个想法是使一个的SQLite本地数据库使用时,该设备具有网络没有访问

My first idea was to make an sqlite local database used when the device has no access to web

我想知道是否有一个现有的工具,这使得同步更容易与现有的Postgres数据库一旦设备访问网站

I'd like to know if there is an existing tool, that makes synchronisation easier with the existing postgres database once the device have access to web

推荐答案

下面是这方面的一些非常基本的想法。

Here are some very basic thoughts on this.

在理想的情况下,你会在一般营运元数据同步和你的离线模式将允许插入,只有工作流添加基于元数据的新数据。这将使它很容易仅仅通过发布到Web服务的一个顺序,然后在数据库中标记为这样或完全移除行通过后同步的东西。

In an ideal case, you'd sync in general working meta-data and your off-line mode would allow insert-only workflows adding new data based on that metadata. This would make it fairly easy to sync things through later by merely posting to a web service sequentially and then flagging as such in the db or removing the rows altogether.

如果您有类似的东西去,你可能真的不希望接近SQLite作为一个RDBMS。你可能想要的是大多是用来存储挂起requirests,或东西,将存储的东西像JSON有效载荷您稍后发送的宽表结构。这意味着你的本地数据库将被设计不在身边你的数据模型,但在你的Web服务的API。

If you go with something like that, you probably don't really want to approach sqlite as an rdbms. What you probably want is a wide table structure designed mostly to store pending requirests, or something that will store things like json payloads you will send later. This means your local db will be designed not around your data model but around your web service API.

如果你要进入更新(覆盖工作流程),那么你就需要投入大量的精力来解决冲突,但基本上适用相同。你可能想增添了不少更像时间戳和其他解决冲突相关的数据信息。

If you have to get into update (overwriting workflows) then you need to put a lot of effort into conflict resolution but the same basically applies. You probably want to add a lot more information like timestamps and other conflict-resolution-related data.

从那里,但是你应该能够重新使用应用程序的API做同步,而不是寻找一个特定的工具来做到这一点。

From there however you should be able to re-use your application API to do the sync rather than looking for a specific tool to do it.

这篇关于Android应用程序脱机模式,与远方的本地数据库SQLite数据库同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆