Hi guys,
I have an app (using JRDC), this app downloaded data from server and then save it to local sqlite database.
Usually this process goes OK, but on a phone, data downloaded OK but not saved on local sqlite database.
Here is the declaration on sqlite table
And here is the codes to download and save to local sqlite
After that strange behaviour, I installed B4 Bridge on that phone, compile and run again the app while still connected to B4a Bridge, add only this code to Sub UpdateDsc : LogColor("OK",Colors.Cyan), and it worked as expected!
Any of you can shed a light, why this is happen?
My OS is Android 10, B4A 12,2, and DbUtils version 1.09.
I have an app (using JRDC), this app downloaded data from server and then save it to local sqlite database.
Usually this process goes OK, but on a phone, data downloaded OK but not saved on local sqlite database.
Here is the declaration on sqlite table
B4X:
Sub Service_Create
Private rtp As RuntimePermissions
Main.PUB_InstDir= rtp.GetSafeDirDefaultExternal("")
Provider.Initialize
End Sub
Sub Service_Start (StartingIntent As Intent)
Private dbName As String = "mydata.dat"
Try
If File.Exists(Main.PUB_InstDir,dbName) = False Then
If File.Exists(File.DirRootExternal & "/APP",dbName) = True Then
File.Copy(File.DirRootExternal & "/APP",dbName,Main.PUB_InstDir, dbName)
Else
File.Copy(File.DirAssets, dbName, Main.PUB_InstDir, dbName)
End If
End If
Main.SQLTbl.Initialize(Main.PUB_InstDir, dbName, False)
Catch
ExitApplication
End Try
End Sub
And here is the codes to download and save to local sqlite
B4X:
Sub UpdateDsc(result As DBResult)
Dim ListOfMaps As List
Dim m As Map
Private IdSrc As Int
ListOfMaps.Initialize
Main.SQLTbl.BeginTransaction
Try
Main.SQLTbl.ExecNonQuery("delete from m_dsc")
For Each records() As Object In result.Rows
IdSrc = records(1)
m.Initialize
m.Put("Id",records(0))
If records(0) = 1 Then
m.Put("Id_Src",Main.PUB_DPT_ID)
Else
m.Put("Id_Src",records(1))
End If
m.Put("Dsc_Nm",records(2))
m.Put("Dsc",records(3))
ListOfMaps.Add(m)
Next
DBUtils.InsertMaps(Main.SQLTbl, "m_dsc", ListOfMaps)
Main.SQLTbl.TransactionSuccessful
LogColor("OK",Colors.Cyan)
Catch
End Try
Main.SQLTbl.EndTransaction
ProgressDialogHide
End Sub
After that strange behaviour, I installed B4 Bridge on that phone, compile and run again the app while still connected to B4a Bridge, add only this code to Sub UpdateDsc : LogColor("OK",Colors.Cyan), and it worked as expected!
Any of you can shed a light, why this is happen?
My OS is Android 10, B4A 12,2, and DbUtils version 1.09.