简体   繁体   English

如何使android应用在离线模式下在android中工作

[英]How to make an android app work in offline mode in android

I want to know how i can make my app work in offline mode and store the data on a local database on the android device. 我想知道如何使我的应用程序在脱机模式下工作并将数据存储在android设备上的本地数据库中。

I am using mongodb database and fetching the data by using JSON Parsing. 我正在使用mongodb数据库,并使用JSON解析来获取数据。

What should i use to make my app run in offline mode and also update the changes made on the server ? 如何使我的应用程序以脱机模式运行并更新服务器上所做的更改?

Which tools should i use ,also which is the best and easy method to implement this? 我应该使用哪些工具,哪个是实现此目的的最佳和简便方法?

Thanks in advance. 提前致谢。

  1. first you create local SQLite Date Base 首先,您创建本地SQLite日期库
  2. in that create one extra column like "noNet" ... 在其中创建一个额外的列,如“ noNet” ...
  3. In this column you save your data when phone in offline mode and then send data to web server when phone is online 在此列中,您可以在手机处于离线模式时保存数据,然后在手机在线时将数据发送到Web服务器

This question is a bit older now, but I'd like to add what I believe is a good architecture approach to solving this. 这个问题现在有点老了,但是我想补充一点,我认为这是解决这个问题的一种好的架构方法。

Take a look at the tech talk given by Yigit and Adam at the Android Dev summit. 看看Yigit和Adam在Android Dev峰会上进行的技术演讲。 https://plus.google.com/+AndroidDevelopers/posts/3C4GPowmWLb https://plus.google.com/+AndroidDevelopers/posts/3C4GPowmWLb

Seems the core components are: 似乎核心组件是:

Those 3 together get you most of what you will probably need. 这三者共同为您提供了您可能需要的大部分东西。 Their tech talk (first link above) really details these things better, and there's a final example application you can take a look at as well: https://github.com/yigit/dev-summit-architecture-demo 他们的技术演讲(上面的第一个链接)确实更好地详细说明了这些事情,还有一个最终的示例应用程序您也可以看一下: https : //github.com/yigit/dev-summit-architecture-demo

If you have an option, you can go for couchdb or couchbase which provide couchlite for android and sync is taken care by itself. 如果您有选择的话,您可以选择沙发床或沙发床,它们为android提供沙发床,并且同步会自行处理。

you can also refer this thread here SQLite on Android and MongoDB with synchronization 您还可以在此处将此线程引用为Android和MongoDB上具有同步的SQLite

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM