【问题标题】:Compare old cache with new data in android Volley将旧缓存与 android Volley 中的新数据进行比较
【发布时间】:2016-07-14 16:28:24
【问题描述】:

我正在使用Volley 库在我的新闻应用程序中进行缓存。我想在第一次运行时缓存所有新闻,然后每次打开应用程序时都会显示我的应用程序中的新新闻计数。为此,我再次获取所有数据并将其与我的缓存数据进行比较。有没有其他方法可以获取与我的缓存相比新的部分数据?

【问题讨论】:

    标签: android caching android-volley


    【解决方案1】:

    访问volley缓存中的数据。你可以这样做。

    if(Requestqueue.getCache().get(YourUrl)!=null){
      //if the response is already cached you can access it from cache
      String cachedResponse = new String(Requestqueue.getCache().get(YourUrl).data);
    
            //Here you can write your code to compare your new data with your cached Data.
    
     }
    

    我希望这会有所帮助。谢谢。

    【讨论】:

    • 我知道,我想知道有什么方法可以获取新数据,而不是缓存所有数据
    • 好的。请解释一下你想做什么?你想用缓存的数据检查获取的响应吗?
    • 哦。我明白你了现在。为此,您必须以正确的方式设计您的网络服务。
    • 你不想获取已经存储在缓存中的数据吧?
    • 不,你能不能给我解释一下关于设计 web 服务的更多信息?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-02
    • 1970-01-01
    相关资源
    最近更新 更多