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 As String(TableName))
Return count > 0
End Sub
'Deletes all the records of a table
Public Sub ClearTable(SQL As SQL, TableName As String)
If TableExists(SQL, TableName) = False Then
Return
End If
SQL.ExecNonQuery("DELETE FROM " & TableName)
End Sub
Last edited: