Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在列表视图中为我的项目创建一个添加收藏夹功能。但我不知道我应该使用哪种方法,共享首选项或 sqlite DB。有人可以对此发表意见吗?
谢谢
如果你想保存小数据,比如 ID 或其他东西,你应该使用SharedPreferences- 它们快速且易于使用。保持String与前任一样。逗号作为分隔符或仅使用Set.
SharedPreferences
String
Set
如果你想保存大量结构化、有组织的数据,保存整个对象,最好使用 SQLite 数据库。这更复杂。
记住这两个选项都是读/写操作,所以它们不能在主线程上完成。