- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我的应用程序需要一个类似于队列的数据结构:将数据放入其中,从中接收数据,类似于 FIFO。对于数据,我现在指的是简单的字符串,稍后可能是更复杂的对象。问题是无论 Android 正在做什么,队列及其内容都应该是持久的。如果应用程序关闭并重新打开(甚至 Android 重启),队列应该具有与应用程序关闭之前相同的状态和数据。
我认为队列必须在引擎盖下使用某种存储,最好是设备的内部存储。也许你可以集思广益如何实现这一点。队列不一定必须在我的应用程序中运行,它也可以是某种松散耦合的后台服务,如果这在 Android 中是可能的(但对我的应用程序是私有(private)的)。
最佳答案
五月 squareup是一个不错的选择。
QueueFile is a lightning-fast, transactional, file-based FIFO. Addition and removal from an instance is an O(1) operation and is atomic. Writes are synchronous; data will be written to disk before an operation returns. The underlying file is structured to survive process and even system crashes and if an I/O exception is thrown during a mutating change, the change is aborted.
关于java - 如何在Android上实现持久化队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9033476/
我是一名优秀的程序员,十分优秀!