Search code examples
androidfirebasegoogle-cloud-firestorefirebase-storageoffline-caching

Caching videos Firestore


I display photos & videos inside my Android application.

The photos caching is ensured by Glide, but i would like also to cache the videos downloaded from my Firestore database.

Everytime i restart the application it takes ages to load all videos (URLs are stored in Firestore, coming from Firebase storage and are displayed inside a RecyclerView).

I am aware that firestore allows persistence for the client data when it becomes offline, but not in my case and i thought it was automatic...

What should i do ?


Solution

  • If the videos are read from Firebase Storage, they are not cached locally automatically.

    You have a few options though:

    • You can store them locally yourself though for example by downloading them to local files. You'd then need to manage this local cache yourself, or find a library to do this.
    • If you read the files from download URLs, you can use the HttpsURLConnection Response Cache as a local cache.

    See: