简体   繁体   English

Android缓存框架

[英]Android Caching Framework

In iOS Development there is three20 which takes care of all the caching (lists, webviews etc.) but is there something similar to this which takes care of the caching automatically? 在iOS开发中,有3个20负责所有缓存(列表,Web视图等),但是是否有与此类似的东西可以自动进行缓存? Or would we have to do this all by ourselves? 还是我们必须独自完成这一切? If so what is the recommended way? 如果是这样,推荐的方法是什么? Sqlite Database? SQLite数据库? Shared Prefs? 共享偏好?

The thing is that we have over 10 different views (including lists, webviews and more lists) and we are loading data from the web. 事实是,我们有10多种不同的视图(包括列表,Web视图和更多列表),并且正在从Web加载数据。 We want to show the cached data if it could not be loaded for a certain time. 如果要在一定时间内无法加载缓存的数据,我们想显示它。

Thanks alot for your help! 非常感谢你的帮助!

WebView might have caching enabled, but it is not so with other views.You have to implement your own cache. WebView可能已启用缓存,但其他视图却未启用。您必须实现自己的缓存。 However since SQLite is available on android, is pretty easy to implement a DB based cache. 但是,由于SQLite在Android上可用,因此很容易实现基于数据库的缓存。 For example DataCache.java in this project . 例如, 该项目中的 DataCache.java Just make it a global singleton in Application class and use from anywhere in your code. 只需在Application类中使其成为全局单例,并在代码中的任何位置使用即可。

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

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