如何与本地数据库同步并解析? [英] How to do sync with local database and parse?

查看:109
本文介绍了如何与本地数据库同步并解析?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序,该应用程序应可离线使用.在应用程序中,当在脱机模式下创建记录时,它们存储在本地数据库(sqlite)中,当Internet连接可用时,在脱机期间创建的记录应与解析同步.

I have an Android application where the app should work offline. In the app when the records are been created during offline mode they are stored in the local database(sqlite), when the internet connection is available the records that were been created during offline should sync with parse.

如何在Android中做到这一点?

How can I do it in Android?

推荐答案

运行后台服务以检查您的手机是否已连接到互联网时很简单,然后 从本地数据库中的一个列表中获取数据,然后将数据解析到另一个列表中

Simple while run a background service to check whether your mobile is connected to internet or not,then get the data from your Local Database in one list and then Parse data into other list

public Collection nonOverLap(Collection coll1, Collection coll2) {
   Collection result = union(coll1, coll2);
   result.removeAll(intersect(coll1, coll2));
   return result;
} // will return elements missing in parse

然后将nonOverlap更新为解析Db:)

Then update the nonOverlap into parse Db :)

这篇关于如何与本地数据库同步并解析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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