Android Question How do i link sql to b4xTable

Scantech

Well-Known Member
Licensed User
Longtime User
I can't initialize the .db (database)

B4X:
        If FirstTime Or blnFileAvailable = False Then
            'check external first
            If File.Exists(File.DirRootExternal, Starter.DiagReportDatabase & "diagreport.db") Then
                B4XTable1.sql1.Initialize(File.DirRootExternal, Starter.DiagReportDatabase & "diagreport.db", False)
                blnFileAvailable = True
            Else If File.Exists(File.DirInternal, Starter.DiagReportDatabase & "diagreport.db") Then
                B4XTable1.sql1.Initialize(File.DirInternal, Starter.DiagReportDatabase & "diagreport.db", False)
                blnFileAvailable = True
            Else
                blnFileAvailable = False
            End If
        End If


*** Service (starter) Create ***
Using FileProvider? true
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
true
FILE NOT AVAILABLE ...VALIDATEPAIDUSER
** Activity (main) Resume **
android.permission.WRITE_EXTERNAL_STORAGE true
android.permission.ACCESS_COARSE_LOCATION true
false, Billing service unavailable on device. (response: 3:Billing Unavailable)
Subscriptions supported: false
*** Service (comserial) Create ***
** Service (comserial) Start **
*** Service (communicationroutine) Create ***
** Service (communicationroutine) Start **
** Activity (main) Pause, UserClosed = false **
No wakelock.
** Activity (diagreport) Create, isFirst = true **
Error occurred on line: 65 (DiagReport)
java.lang.NullPointerException: null receiver
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at scantech.cardiagnosticpro.diagreport._inittableandsql(diagreport.java:397)
at scantech.cardiagnosticpro.diagreport._activity_create(diagreport.java:389)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at scantech.cardiagnosticpro.diagreport.afterFirstLayout(diagreport.java:104)
at scantech.cardiagnosticpro.diagreport.access$000(diagreport.java:17)
at scantech.cardiagnosticpro.diagreport$WaitForLayout.run(diagreport.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Error occurred on line: 65 (DiagReport)
java.lang.RuntimeException: Unexpected command: 0
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:426)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at scantech.cardiagnosticpro.diagreport._inittableandsql(diagreport.java:397)
at scantech.cardiagnosticpro.diagreport._activity_create(diagreport.java:389)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at scantech.cardiagnosticpro.diagreport.afterFirstLayout(diagreport.java:104)
at scantech.cardiagnosticpro.diagreport.access$000(diagreport.java:17)
at scantech.cardiagnosticpro.diagreport$WaitForLayout.run(diagreport.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
** Activity (diagreport) Resume **
** Activity (diagreport) Pause, UserClosed = true **
** Service (comserial) Destroy **
** Service (communicationroutine) Destroy **
** Service (starter) Destroy (ignored)**

When I delete a row in b4xTable, I need the .db file to be updated and the row removed from b4xTable. Can i link SQL .db to b4xTable?

I do use the B4XTable1.SetData(Data) but deleting part is where i am struggling
 
Last edited:

Scantech

Well-Known Member
Licensed User
Longtime User
I did that. I have a database file that is initialized with SQL. I am dealing with 2 SQL since i can't link my database file to b4xTable i am doing this for deleting rows at b4xTable and updating SQL. Its working good so far. But i don't like the idea of 2 different SQL.

B4X:
            Starter.sql1.ExecNonQuery2("DELETE FROM diagnosticlog WHERE ID = ?", Array(RowId))
            B4XTable1.sql1.ExecNonQuery2("DELETE FROM data WHERE rowid = ?", Array (RowId))
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
is this .DiagReportDatabase a prefix?
Starter.DiagReportDatabase & "diagreport.db"
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
this works? because the path and name is a separated parameter here
File.Exists(Dir,FileName)
 
Upvote 0
Top