I am learning how to use SQLite and DbUtils.
I have written code that creates a db and a table. It then writes values to the table. However it does not seem to be able to retrieve them. Not too sure what is wrong with the code, as it is pretty much what is in the tutorial video.
Here is the code:
I get this error:
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 2
Any suggestions?
I have written code that creates a db and a table. It then writes values to the table. However it does not seem to be able to retrieve them. Not too sure what is wrong with the code, as it is pretty much what is in the tutorial video.
Here is the code:
B4X:
//Create Table
DBUtils.CreateTable(sql1, "tbl_User", CreateMap( _
"cl_Parameter" : DBUtils.DB_TEXT, _
"cl_Value" : DBUtils.DB_TEXT), _
"cl_Parameter")
//Insert Values
Dim rows As List
rows.Initialize
Dim row As Map
row = CreateMap("cl_Parameter" : "name", "cl_Value" : "John")
rows.Add(row)
row = CreateMap("cl_Parameter" : "surname", "cl_Value" : "Williams")
rowS.Add(row)
DBUtils.InsertMaps(sql1,"tbl_User", rows)
//Read Inserted Values
Dim queryResult As ResultSet = sql1.ExecQuery("SELECT cl_Parameter, cl_Value FROM tbl_Parameters")
Log(queryResult.GetString("cl_Parameter"))
Log(queryResult.GetString("cl_Value"))
I get this error:
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 2
Any suggestions?