问题
I am using Firebase realtime database in my Android application. I have replica of database in local device using below line of code -
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
But it will sync all the tables between local and global database. I only want few table need to be sync not all.
Is there any way to only sync few tables in local memory and rest of table Android device will read from global database?
回答1:
When you are using the following line of code:
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
All the data that the user recently received is cached to disk.
Is there any way to only sync a few tables in local memory and the rest of the table android device will read from the global database?
No, there is not! There is no way to exclude certain nodes from that disk persistence. Unfortunately, you cannot choose whether a node should be or shouldn't be cached on the disk. It's all or nothing.
来源:https://stackoverflow.com/questions/54047550/firebase-android-only-need-specific-table-to-be-in-local-device