Hi All,
Wondered if any of you had this problem.
- Developed and App that connects to an sqLite DB on the internal storage
- Works fine reads and writes to database correctly.
- B4A hangs and I have to restart it.
- Compile and run the program in debug and release, but when it tries to initalise the database the initialisation fails.
- Try all sorts of things to fix it as I am thinking the db has been damaged or hasn't been copied on installation.
- Tried db initialization almost identical to Erel's SQLExample V1:
The only difference between Erel's and my code is i shown below:
My Code:
- Restored a previous backup; the backup ran fine
- Updated the restored file with the updated code from the version that failed to run by copying and pasting the text in sections.
Voila!! It works!!
I am not sure why B4A crashed. It does it so infrequently (perhaps twice) that the sequence of actions that causes it is difficult to determine. I think that it occurred after using the Designer, but I can't be sure.
Best regards
Rob
Wondered if any of you had this problem.
- Developed and App that connects to an sqLite DB on the internal storage
- Works fine reads and writes to database correctly.
- B4A hangs and I have to restart it.
- Compile and run the program in debug and release, but when it tries to initalise the database the initialisation fails.
- Try all sorts of things to fix it as I am thinking the db has been damaged or hasn't been copied on installation.
- Tried db initialization almost identical to Erel's SQLExample V1:
B4X:
Public DBFileDir = File.DirDefaultExternal As String
If File.Exists(DBFileDir, DBFileName) = False Then
File.Copy(File.DirAssets, DBFileName, DBFileDir, DBFileName)
End If
SQL1.Initialize(DBFileDir, DBFileName, True)
ColLineWidth = 1dip
RowLineWidth = 1dip
RowHeight = 30dip
RowHeight_1 = RowHeight - RowLineWidth
lblHeight = 30dip
edtHeight = 50dip
TotalHeight = lblHeight + edtHeight + 10dip
' initialize the RowID
RowID.Initialize
The only difference between Erel's and my code is i shown below:
B4X:
Private dbFolder As String 'My folder variable
Public DBFileDir = File.DirDefaultExternal As String 'Erel's folder variable
My Code:
My Project's DB Initaliszation:
Sub Class_Globals
Private dbFilename As String
Private dbFolder As String
Private sqlDB As SQL
End Sub
dbFolder = DBUtils.CopyDBFromAssets (dbFileNameStr)
If dbFolder.Length = 0 Then ' Return <> 0 if error
dbFilename = ""
Return 1
End If
dbFilename = dbFileNameStr
'Initialise sql object
'Open the DB
Try
If sqlDB.IsInitialized = False Then
sqlDB.Initialize(dbFolder, dbFilename, False)
End If
Catch
#If LOGGING_ON
Log(LastException.Message)
#End If
ToastMessageShow("Could not open Database resistanceTrainer.sqlite", True)
Return 2
End Try
'Check the database
Dim qryStr As String = "PRAGMA integrity_check;"
Dim qryOutList As List = DBUtils.ExecuteMemoryTable(sqlDB, qryStr, Null, 1)
Dim row() As String = qryOutList.Get(0)
If row(0).CompareTo("ok") <> 0 Then
Return 1
End If
Return 0
- Restored a previous backup; the backup ran fine
- Updated the restored file with the updated code from the version that failed to run by copying and pasting the text in sections.
Voila!! It works!!
I am not sure why B4A crashed. It does it so infrequently (perhaps twice) that the sequence of actions that causes it is difficult to determine. I think that it occurred after using the Designer, but I can't be sure.
Best regards
Rob