Reputation: 363
Is there a way to make a Firestore collection available offline on Android? I know there's setPersistenceEnabled(true), but I think it only caches data after I first access it. There's no upfront caching.
I would like to have certain collections to be always fully local stored, so that if device is offline it can still query for data that have never been queried before. (Of course it would require internet connection at some point in time so that data can be synched)
I thought on doing a get on the whole collection at some point, and then attaching a listener so that the app gets new data. Is it a good practice? Is there anything better?
Upvotes: 1
Views: 404
Reputation: 317372
Yes, you have to query the data before it's available locally. There are no other options.
It's a good practice is it meets the requirements of your app, and you're willing to pay for the cost of that query, and all the changes to the doucments that happen over time (each changed document while the listener is attached costs 1 read).
Upvotes: 3