Android Question Cursor not initialized error

DickD

Active Member
Licensed User
I get the error "Can't read row 0 col 3 from CursorWindow. Make sure the cursor is initialized correctly...". The error occurs on the line shown below. I see that this cursor not initialized error is an old thread but I don't see that the problem was ever clearly resolved.

B4X:
bytes = cursor1.GetBlob("myPicture")

Full Sub below:
B4X:
Sub displayPersonalInfo
Dim cursor1 As Cursor
Dim bytes() As Byte
NewFileFlag = False
Try
cursor1 = SQL1.ExecQuery("SELECT screename, phonenumber, YOB, myPicture FROM PersonalInfo WHERE ID = 1")
If cursor1.RowCount = 0 Then
Msgbox("","No Personal Information found")
NewFileFlag = True
cursor1.Close
Else
cursor1.Position = 0
bytes = cursor1.GetBlob("myPicture")
If bytes.Length > 0 Then
UI.InitializeFromBytesArray(bytes, 0, bytes.Length)
bmp.Initialize2(UI)
End If
PN = cursor1.GetString("phonenumber")
SN = cursor1.GetString("screename")
YB = cursor1.GetString("YOB")

cursor1.Close
End If
Catch
Msgbox("error in reading from PersonalInfo table","")
Log(LastException.Message)
cursor1.Close
End Try
Activity.LoadLayout("PersonalInfo")
ScreenName.Text = SN
PhoneNumber.Text = PN
YOB.Text = YB
UserImage.Bitmap = bmp
End Sub
 

keirS

Well-Known Member
Licensed User
Longtime User
I suspect your blob is too big. Android only supports blobs of a certain size (2mb I think)
 
Upvote 0

DickD

Active Member
Licensed User
I suspect your blob is too big. Android only supports blobs of a certain size (2mb I think)
Hmmmmm ... it is a photo taken on the phone and pulled out of the gallery. What can I do about it? Can it be edited in code to make it smaller or make the byte array larger?
 
Upvote 0

DickD

Active Member
Licensed User
Yes, with testing it does look like it crashes on images > 1mb. Thanks for your help. Will look into CreateScaledBitmap
 
Upvote 0
Top