See here.
You can set the size of the disk cache using the InternalCacheDiskCacheFactory.
builder.setDiskCache(new InternalCacheDiskCacheFactory(context, yourSizeInBytes));
You can apply in this your project like below:
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.util.Log;
import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
import com.bumptech.glide.module.GlideModule;
import com.example.MyApplication;
import java.util.Locale;
public class LimitCacheSizeGlideModule implements GlideModule {
@Override
public void applyOptions(Context context, GlideBuilder builder) {
if (MyApplication.from(context).isTest())
return; // NOTE: StatFs will crash on robolectric.
builder.setDiskCache(new InternalCacheDiskCacheFactory(context, yourSizeInBytes));
}
@Override
public void registerComponents(Context context, Glide glide) {
}
}
and then in your manifest add it like this
<manifest
...
<application>
<meta-data
android:name="YourPackageNameHere.LimitCacheSizeGlideModule"
android:value="GlideModule" />
...
</application>
</manifest>