简体   繁体   中英

Getting LiveData updates in multiple processes

In my Android application I use the Room API to persist data that comes from the network. The app is split into several processes, with one of them responsible for syncing the data (implementing SyncAdapter). The UI is running on a different process, with it's own DAO to access the DB. My issue is that the LiveData I query on the UI process, doesn't get any updates when the SyncAdapter writes new data to the DB. Because the DB is shared between processes, I expected the OnChanged to be called on all processes that have LiveData that reflects the DB, meaning that all processes can observe data base changes

enableMultiInstanceInvalidation introduced in room 2.1.0 may help you official docs

You will need to implement your own IPC mechanism to pass events from process to process. This is not significantly different than using SQLite directly, or using most other observer frameworks (eg, data binding observables).

Or, switch to having a single process, in which case your existing implementation may work just fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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