Hi,
I am starting a new project and learning about the starter service.
In the past I have been Initializing SQL objects in a code module, and then calling the code from the Main module.
For Example..
Code Module: MyCodeModule
Main Module:
The above seems to work.
However, when using the starter service, should I do:
Service: Starter
Main Module:
Would the above work if I move the code from the Main module to the starter service? Or do I need to Initialize the SQL object in the service module and not the code module ?
I am starting a new project and learning about the starter service.
In the past I have been Initializing SQL objects in a code module, and then calling the code from the Main module.
For Example..
Code Module: MyCodeModule
B4X:
Public Sub InitializeDatabase
If Database.IsInitialized = False Then
If File.Exists(File.DirInternal,"MyDatabase.db") = True Then
Database.Initialize(File.DirInternal,"MyDatabase.db",False)
Return
End If
If File.Exists(File.DirInternal,"MyDatabase.db") = False Then
Database.Initialize(File.DirInternal,"MyDatabase.db",True)
CreateAppDatabase ' this will create tables etc. in the database from another sub in the code module
Return
End If
End If
End Sub
Main Module:
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
MyCodeModule.InitializeDatabase
End If
End Sub
The above seems to work.
However, when using the starter service, should I do:
Service: Starter
B4X:
Sub Service_Create
MyCodeModule.InitializeDatabase
End Sub
Main Module:
B4X:
Sub Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
StartService(Starter)
End if
End Sub
Would the above work if I move the code from the Main module to the starter service? Or do I need to Initialize the SQL object in the service module and not the code module ?
Last edited: