Hi,
I've read and used Life Cycle and FirstTime at http://www.b4x.com/forum/basic4andr...87-android-process-activities-life-cycle.html
Here's the procedure to explain the fail:
- Installation of my app drops tables, builds the SQLite, fills default data, db data is fresh/default, PASS.
- Close and Re-open the app, all db data is preserved, PASS.
- Power reset the device, open the app, db data is fresh/default, FAIL.
Verified:
- FirstTime = False when re-opening app. Works like a champ.
- FirstTime = True when opening app after power reset. This is my problem.
- db data is preserved after power reset before calling my app.
How to preserve db data after device power reset ?
How to have FirstTime = False every time after initial install ?
Here's the basic structure of my code:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
ProgressDialogShow("Initializing database...")
SQL1.Initialize(File.DirDefaultExternal, DBFileName, True)
CreateTables
FillTables
ProgressDialogHide
Else
SQL1.Initialize(File.DirDefaultExternal, DBFileName, True)
End If
.... more stuff to initialize
End Sub
Sub CreateTables
SQL1.ExecNonQuery("DROP TABLE IF EXISTS tblCust")
..... repeated for all tables.
SQL1.ExecNonQuery("CREATE TABLE tblCust (" <elements> ")
..... repeated for all tables.
End Sub
Sub FillTables
Uses List of Maps to load data into tables.
End Sub
I have found answers to ALL my questions in this forum, except this one.
This is my first post :*)
Thank-you to everyone !
Kevin
I've read and used Life Cycle and FirstTime at http://www.b4x.com/forum/basic4andr...87-android-process-activities-life-cycle.html
Here's the procedure to explain the fail:
- Installation of my app drops tables, builds the SQLite, fills default data, db data is fresh/default, PASS.
- Close and Re-open the app, all db data is preserved, PASS.
- Power reset the device, open the app, db data is fresh/default, FAIL.
Verified:
- FirstTime = False when re-opening app. Works like a champ.
- FirstTime = True when opening app after power reset. This is my problem.
- db data is preserved after power reset before calling my app.
How to preserve db data after device power reset ?
How to have FirstTime = False every time after initial install ?
Here's the basic structure of my code:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
ProgressDialogShow("Initializing database...")
SQL1.Initialize(File.DirDefaultExternal, DBFileName, True)
CreateTables
FillTables
ProgressDialogHide
Else
SQL1.Initialize(File.DirDefaultExternal, DBFileName, True)
End If
.... more stuff to initialize
End Sub
Sub CreateTables
SQL1.ExecNonQuery("DROP TABLE IF EXISTS tblCust")
..... repeated for all tables.
SQL1.ExecNonQuery("CREATE TABLE tblCust (" <elements> ")
..... repeated for all tables.
End Sub
Sub FillTables
Uses List of Maps to load data into tables.
End Sub
I have found answers to ALL my questions in this forum, except this one.
This is my first post :*)
Thank-you to everyone !
Kevin
Last edited: