Android Question KeyValueStore GetBitmap Issue

lucasheer

Active Member
Licensed User
Longtime User
Hello!

I am saving/loading images locally to save data usage for my users.

Saving images works fine:

Saving Images:
Dim j As HttpJob
            j.Initialize("", Me)
           
            j.Download(Starter.staticAREdURL & "public/articleImages/" & article.img)
           
            Wait For (j) JobDone(j As HttpJob)
            If j.Success Then
               
                Dim myBitmap As Bitmap = j.GetBitmap
                FillImageToView(myBitmap, pnlCardImage, True)
                Starter.kvs.PutBitmap("news_" & article.img, myBitmap)
               
               
            Else
            pnlCardImage.Height = 0
            End If

However, whenever I try to use the kvs.GetBitmap, I get this error:

B4X:
android.database.sqlite.SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1

B4X:
If(Starter.kvs.ContainsKey("news_" & article.img)) Then
           
            Try
                Dim tmpBitmap1 As Bitmap = Starter.kvs.GetBitmap("news_" & article.img)
                FillImageToView(tmpBitmap1, pnlCardImage, True)
            Catch
                Log(LastException)
            End Try
        Else

The image that it's trying to load is a 497 KB jpeg.

Smaller images seem to work fine as well. I've been using 15-50KB just fine.

Thank you!
 

lucasheer

Active Member
Licensed User
Longtime User
I figured out that the max file size of the CursorWindow is ~110KB.

So I compressed my images on the server-side to a max size of 110KB, which doesn't really look super great. Does anyone have suggestions on how I might fix this?

If I could get to 200KB, that's pretty crisp no matter which image.
 
Upvote 0

lucasheer

Active Member
Licensed User
Longtime User
Instead of using KVS, I decided just to save/load the bitmaps from File.DirInternal.

The size is limitless now :)

Thank you!
 
Upvote 0
Top