Android Code Snippet SQLite - check table exists

Before we can insert items, we should check, whether the table exists.

B4X:
Public Sub CheckTableExists(sql As SQL,DBName As String) As Boolean 
    If sql.ExecQuerySingleResult("SELECT count(*) FROM sqlite_master WHERE type='table' AND name ='" & DBName & "'") = 0 Then
        Return False
        Else
        Return True
    End If 
End Sub
 
Last edited:

KMatle

Expert
Licensed User
Longtime User
Cookies are required to use this site. You must accept them to continue using the site. Learn more…