java如何使用带多FirestoreRecyclerAdapter的房间?
我在MainActivity
中使用4RecycleView
,它使用FirestoreRecyclerAdapter
从Cloud Firestor加载数据。现在我想使用Room
为ReceiptActivity
中的用户创建收据
我做了所有的工作人员,但当我试图删除和更新Room
中的项目时,出现了一些错误。我的应用程序正在崩溃,所以我想问一下,我所做的与我所做的是否存在冲突?如果没有,请用最佳实践来指导我。提前谢谢
# 1 楼答案
使用Cloud Firestore时,offline persistence:
这意味着Firestore将在用户设备上创建整个数据库的本地(内部)副本。因此,不需要添加额外的本地数据库,也可以实现您想要的相同功能,因为默认情况下,本地数据库已经存在
此外,如果只需要从缓存中获取数据,可以通过DocumentReference.get(Source source)和Query.get(Source source)方法实现
因此,我们现在可以将参数传递给源
DocumentReference
或Query
,这样我们就可以强制从server only
、chache only
或尝试服务器检索数据,并返回到缓存