2

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 ?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Tom3652
  • 2,540
  • 3
  • 19
  • 45
  • 1
    If the videos are read from Firebase Storage, they are **not** stored locally automatically. – Frank van Puffelen Apr 11 '20 at 13:41
  • Thanks for the reply, is there any other way to do this with Firestore (workaround to not use the URL of Firebase Storage) ? If not, i will find another solution. – Tom3652 Apr 11 '20 at 13:44
  • I'd recommend using Firestore for storing files. While it allows it, there are better solutions, and you definitely don't want files to be kept locally in the SQLite database that Firestore uses for its local cache. – Frank van Puffelen Apr 11 '20 at 13:51

1 Answers1

3

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:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807