Advertisement
lscofield

ExoPlayerCache

Aug 4th, 2022
777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. public class ExoPlayerCache {
  2.     private static SimpleCache cache;
  3.  
  4.     public static SimpleCache getInstance(Context ctx){
  5.         DatabaseProvider dp =
  6.                 new DefaultDatabaseProvider(
  7.                         new SQLiteOpenHelper(
  8.                                 ctx,
  9.                                 "ExoPlayer",
  10.                                 null,
  11.                                 1) {
  12.             @Override
  13.             public void onCreate(SQLiteDatabase db) { }
  14.             @Override
  15.             public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { }
  16.         });
  17.  
  18.         if (cache == null) {
  19.             cache = new SimpleCache(
  20.                     new File(ctx.getCacheDir(),
  21.                             "ExoPlayerCache"),
  22.                     new LeastRecentlyUsedCacheEvictor(50 * 1024 * 1024),
  23.                     dp);
  24.            /* cache = new SimpleCache(
  25.                     new File(ctx.getCacheDir(),
  26.                     "ExoPlayerCache"),
  27.                     new LeastRecentlyUsedCacheEvictor(50 * 1024 * 1024));*/
  28.         }
  29.  
  30.         return cache;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement