到缓存JSON的最好方法 [英] The best way to caching json

查看:134
本文介绍了到缓存JSON的最好方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序应该工作不仅在网上,还处于脱机模式。出于这个原因,我正在考虑寻找兑现数据的最佳方式。 I't像人物使用共享preference用于存储数据,但是在android的文档writen允许的最大值为preferences值是8192,我不知道这是好不好?我试图传递出这样的想法尝试使用FileCashing或sqlite的兑现的。

My application should work not only in online but also in offline mode. For that reason I am considering find the best way for cashing data. I't like use SharedPreference for store data but in android documentation writen Maximum size in characters allowed for a preferences value is 8192. I don't know this is ok or not? I tried to pass out of this idea trying to use FileCashing or sqLite cashing.

那么,你认为球员什么是最好的共享preference VS FileCashing或VS SqLiteCaching?

So what you think guys what is the best SharedPreference vs FileCashing or vs SqLiteCaching?

推荐答案

我个人很喜欢这样做下面的方法。创建SQLite数据库,可以把你的内容。然后,直接结合的用户界面来使用适配器及安培的数据库;该发送每当数据被改变,使得在UI可以更新本身的通知内容提供者。最后一块方程是某种形式的同步服务,下载内容,并将其保存到数据库异步的。这样,您就可以管理您的数据很容易,因为它是所有在同一个地方。你必须搞清楚你的​​应用程序中只有一部分是你如何决定何时更新或从数据库中删除的数据。

I personally like to do this the following way. Create a SQLite database that can hold your content. Then, bind the user interface directly to the database using Adapters & Content Providers that send a notification whenever the data is changed so that the UI can update itself. The last piece in the equation is some form of synchronization service that downloads content and saves it to the database asynchronously. That way, you can manage your data very easily because it is all in the same place. The only part you'll have to figure out for your app is how you decide when to update or remove the data from the database.

适配器

<一个href="http://developer.android.com/guide/topics/providers/content-providers.html">ContentProvider

<一个href="http://developer.android.com/reference/android/content/AbstractThreadedSyncAdapter.html">Synchronization

这篇关于到缓存JSON的最好方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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