Android Question Service and SQLite.

Discussion in 'Android Questions' started by dragonguy, Mar 7, 2015.

  1. dragonguy

    dragonguy Active Member Licensed 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:

    Sub Process_Globals
    Dim serv_SQL As SQL
    End Sub

    Sub Service_Create
    If File.Exists(File.DirDefaultExternal, "PhoneData.db3") = True Then
    File.DirDefaultExternal, "PhoneData.db3"True)
    End If
    End Sub
    and then another modules just use code like this:

    Query = "UPDATE TblJob Set TimeIn = ?, WHERE CaseNo = ?"
    Array As String("10:00","1234"))
    is it correct way to use it?
    Last edited: Mar 7, 2015
  2. keirS

    keirS Well-Known Member Licensed User

    You have the right sort of idea but to call a sub from a service you should use CallSubDelayed(). See this tutorial.
    dragonguy likes this.
  3. dragonguy

    dragonguy Active Member Licensed 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?
  4. edgar_ortiz

    edgar_ortiz Active Member Licensed User

    define a transaction in the most recommended.

    At the end you lose nothing.


    dragonguy likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice