Android Question Accessing a sqlite object in Service_Create

Ricky D

Well-Known Member
Licensed User
Longtime User
What code do I use to access the SQL object? I can't see examples anywhere. Is it Starter.mysql for example? I'm asking because I will completely rewrite my app which is for my personal use
 

Ricky D

Well-Known Member
Licensed User
Longtime User
I'd like to know why we get told to do something like this and there is no explanation of code. I'll look at that code when I get home from work
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
What code do I use to access the SQL object? I can't see examples anywhere. Is it Starter.mysql for example?
You initialize the database in the Starter service module and access it from other activities. See below example:
IN SERVICE MODULE:
B4X:
Sub Process_Globals
    Public SQL0 As SQL
End Sub
Sub Service_Create
    Dim TargetFolder As String
    If File.ExternalWritable Then TargetFolder = File.DirRootExternal Else TargetFolder = File.DirInternal
    File.MakeDir(TargetFolder, "products/data")
    SQL0.Initialize(TargetFolder & "/products/data", "products.db", True)
End Sub

IN MAIN ACTIVITY OR OTHER ACTIVITY you access it with: Starter.SQL0
By the way, you seem to be very irritated with most of the answers you are getting ever since you rejoined the forum. Everyone is trying to help you free of charge. Have you wondered that some of your questions are not totally clear either. Cool it down.
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
You initialize the database in the Starter service module and access it from other activities. See below example:
IN SERVICE MODULE:
B4X:
Sub Process_Globals
    Public SQL0 As SQL
End Sub
Sub Service_Create
    Dim TargetFolder As String
    If File.ExternalWritable Then TargetFolder = File.DirRootExternal Else TargetFolder = File.DirInternal
    File.MakeDir(TargetFolder, "products/data")
    SQL0.Initialize(TargetFolder & "/products/data", "products.db", True)
End Sub

IN MAIN ACTIVITY OR OTHER ACTIVITY you access it with: Starter.SQL0
By the way, you seem to be very irritated with most of the answers you are getting ever since you rejoined the forum. Everyone is trying to help you free of charge. Have you wondered that some of your questions are not totally clear either. Cool it down.
Because of my stressful job I won't post here ever again
 
Upvote 0
Top