Hello,
I have read Erel's tutorial on CallSubDelayed from here: http://www.b4x.com/android/forum/th...teract-between-activities-and-services.18691/
What I am doing is this:
On a Activity (Main) I have a label (label1) and as soon as the Activity runs I am creating a SQL Lite database and loading a whole heap of tables and loading some default data into that table. (approx. 10 tables and 1 row in each table)
I am creating the database using the following code:
'Main' Activity:
'mycodemodule' Code Module:
As you can see I need a way after it has created the tables etc in the CreateDatabase sub to trigger the DatabaseCreated Sub in the main Activity.
I have used CallSub(Main, DatabaseCreated) and it didn't work.
I then searched the forum and found CallSubDelayed(Main,"DatabaseCreated") and that worked.
However, after reading Erel's Tutorial, it says:
Note that you cannot use CallSubDelayed (or CallSub) with code modules.
Would you say since I have it working with CallSubDelayed that it will work on other devices? or is there another way I should be doing this?
The reason I am doing this in a Code module is because I maybe using this code again later in the app and don't want to have the same code multiple times in the app otherwise if I make a change I need to keep going back to multiple places to change the code.
The only other way I thought of doing this was to create a library and call that library and trigger the code from it and just make the change in the library and I only need to change it from there.
I have read Erel's tutorial on CallSubDelayed from here: http://www.b4x.com/android/forum/th...teract-between-activities-and-services.18691/
What I am doing is this:
On a Activity (Main) I have a label (label1) and as soon as the Activity runs I am creating a SQL Lite database and loading a whole heap of tables and loading some default data into that table. (approx. 10 tables and 1 row in each table)
I am creating the database using the following code:
'Main' Activity:
B4X:
Sub Process_Globals
Dim SQL1 As SQL
End Sub
Sub Activity_Create(FirstTime As Boolean)
If File.Exists(File.DirDefaultExternal,"my_database.db") = False Then
'database has not yet been created
SQL1.Initialize(File.DirDefaultExternal, "my_database.db", True)
mycodemodule.CreateDatabase
End If
End sub
Sub DatabaseCreated
Log("Data base is now created")
End Sub
'mycodemodule' Code Module:
B4X:
Public Sub CreateDatabase
' Code here that creates the tables etc..
' ..Create Table..
' ..Load data into table..
'Now once the tables are created I need to fire the DatabaseCreated sub from the Main Activity
End Sub
As you can see I need a way after it has created the tables etc in the CreateDatabase sub to trigger the DatabaseCreated Sub in the main Activity.
I have used CallSub(Main, DatabaseCreated) and it didn't work.
I then searched the forum and found CallSubDelayed(Main,"DatabaseCreated") and that worked.
However, after reading Erel's Tutorial, it says:
Note that you cannot use CallSubDelayed (or CallSub) with code modules.
Would you say since I have it working with CallSubDelayed that it will work on other devices? or is there another way I should be doing this?
The reason I am doing this in a Code module is because I maybe using this code again later in the app and don't want to have the same code multiple times in the app otherwise if I make a change I need to keep going back to multiple places to change the code.
The only other way I thought of doing this was to create a library and call that library and trigger the code from it and just make the change in the library and I only need to change it from there.