Dim cache As B4XCache
cache.Initialize
cache.MaxSize = 20
cache.Put("Image 1", bmp1)
cache.Put("Image 2", bmp2)
cache.Put("Image 3", bmp3)
cache.Put("Image 4", bmp4)
cache.PutEternal("Default Image", bmpDefault)
'Getting an item from the cache, don't assume that it is there:
Dim bmp As B4XBitmap
Dim Key As String = "Image 4"
If cache.ContainsKey(Key) Then
bmp = cache.Get(Key)
Else
'Put also returns the Value.
bmp = cache.Put(Key, XUI.LoadBitmap(...))
End If