Android Question DBUtils.TableExists throwing 'java.lang.ClassCastException'

Amalgamated Sugar

Member
Licensed User
Good day!

I'm trying to create a conditional service on if a table exists. However, when I test for the existence of said table:

B4X:
If (DBUtils.TableExists(Starter.localSQL, "Contracts")) = False Then
        StartService(Contracts)
    
End If

I get the following error message:

B4X:
java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[]
     at b4a.example.dbutils._tableexists(dbutils.java:1148)

I'm using DBUtils version 2.05. Has any one else run into an issue like this?

Thank you in advance!
Michael
 

Amalgamated Sugar

Member
Licensed User
I think I found the issue... In DBUtils v2.05, the Sub 'TableExists' reads:

B4X:
'Tests whether the given table exists
Public Sub TableExists(SQL As SQL, TableName As String) As Boolean
 Dim count As Int = SQL.ExecQuerySingleResult2("SELECT count(name) FROM sqlite_master WHERE type='table' AND name=? COLLATE NOCASE", Array(TableName))
 Return count > 0
End Sub


When I changed 'Array(TableName)' to 'Array As String(TableName)' the sub works...
 
Upvote 0
Top