Android Question Service and SQLite.

dragonguy

Active Member
Licensed User
Longtime User
My application have a one Service and 4 Activity Modules, all need to connect to one SQLite database.
is it only dim sql at Service Module and another 4 Activity Modules can use it?

i mean like this:

Service1 code:

B4X:
Sub Process_Globals
   Dim serv_SQL As SQL
End Sub

Sub Service_Create
   If File.Exists(File.DirDefaultExternal, "PhoneData.db3") = True Then
     serv_SQL.Initialize(File.DirDefaultExternal, "PhoneData.db3", True)
   End If
End Sub

and then another modules just use code like this:

B4X:
Query = "UPDATE TblJob Set TimeIn = ?, WHERE CaseNo = ?"
         Service1.serv_SQL.ExecNonQuery2(Query, Array As String("10:00","1234"))

is it correct way to use it?
 
Last edited:

dragonguy

Active Member
Licensed User
Longtime User
Thanks for reply, i like to ask about when i do insert or update sqlite database, is it need to use BeginTransaction and EndTransaction?
 
Upvote 0
Top