Cannot read blob field

ThePuiu

Active Member
Licensed User
Longtime User
Hi,
I try to read a BLOB field from a local database. For this use the following code:
B4X:
If mySQL.IsInitialized = False Then
mySQL.Initialize(File.DirInternal, "database.db3", False)
End If
Dim Cursor1 As Cursor   
Cursor1 = mySQL.ExecQuery("SELECT POZA FROM POZE WHERE id = (SELECT MIN(id) FROM poze)")    
Cursor1.Position = 0    
Dim Buffer() As Byte 
Buffer = Cursor1.GetBlob("POZA")   
Cursor1.Close()
but I get an error: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 at line: Buffer = Cursor1.GetBlob("POZA").
Cursor1.ColumnCount and Cursor1.RowCount return correct value!
Can please someone tell me what am I doing wrong?
:sign0188:
 

Attachments

  • database.zip
    153 KB · Views: 137

Mahares

Expert
Licensed User
Longtime User
I created a project for your database, since you only included the database in the zip and used your code. But I copied the database to File.DirRootExternal instead of File.DirInternal and it worked fine for me. I did not get any error. It returned 1 record.
Also Cursor1.close() should be Cursor1.close, but that that is not the problem.
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
Strange ... I did a small test project and used the exact same code and ... it works. With DirInternal and DirRootExternal!!! :BangHead:
I don't understand what is happening ...
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
The mystery was solved! In my application was a subroutine called ReadBlob. After I renamed it, everything is back to normal!

Now I have another problem ... it is possible that due to the relatively large number of controls in a layout (20 edittext, 5 imageview, 1 webView and 12 buttons) application to move more slowly? The problem comes when I want to move a marker on the map ... it moves only a few millimeters, regardless of how I want it to move.
 
Upvote 0
Top