Android Question Static code modules cannot handle events

aeric

Expert
Licensed User
Longtime User
Code modules cannot catch events.

What is the proper way for creating reusable code?

I am trying to create a utility module for creating database schema when the app starts for the first time.
It works with B4J and B4i but in B4A it throws the following error in SQL_NonQueryComplete:
Static code modules cannot handle events

Should I use Service Module?

My sample code:
B4X:
Public Sub CreateDBTables As ResumableSub
    Dim Success As Boolean
    Try  
        #If B4J
        Main.DB.InitializeSQLite(Main.DATA_FOLDER, Main.DATA_FILE, False)
        #Else
        Main.DB.Initialize(Main.DATA_FOLDER, Main.DATA_FILE, False)
        #End If
        For i = 1 To script.Length - 1
            Main.DB.AddNonQueryToBatch(script(i), Null)
        Next
        Dim SenderFilter As Object = Main.DB.ExecNonQueryBatch("SQL")
        Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
        If Not(Success) Then
            LogColor(LastException.Message, xui.Color_Red)
        End If
    Catch
        LogColor(LastException.Message, xui.Color_Red)
    End Try
    Main.DB.Close
    Return Success
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
a Class
 
Upvote 1
Top