Android Question Disabling WAL for SQLite database on Android 8

Xardoz

Member
Licensed User
Longtime User
B4X:
    Dim p As Phone
    Dim sql As SQL
   
    If p.SdkVersion >= 26 Then
        Dim r As Reflector
        r.Target = sql
        r.Target = r.GetField("db")
        r.RunMethod("disableWriteAheadLogging")
    End If

At
B4X:
r. RunMethod("disableWriteAheadLogging")
, we get the following error:

Error occurred on line: 286 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:205)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod(Reflection.java:802)
at com.TriXar.Tech_Activities.main._activity_create(main.java:626)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:735)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:360)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at com.TriXar.Tech_Activities.main.afterFirstLayout(main.java:104)
at com.TriXar.Tech_Activities.main.access$000(main.java:17)
at com.TriXar.Tech_Activities.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6695)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:772)
** Activity (main) Resume **
 

walterf25

Expert
Licensed User
Longtime User
B4X:
    Dim p As Phone
    Dim sql As SQL
  
    If p.SdkVersion >= 26 Then
        Dim r As Reflector
        r.Target = sql
        r.Target = r.GetField("db")
        r.RunMethod("disableWriteAheadLogging")
    End If

At
B4X:
r. RunMethod("disableWriteAheadLogging")
, we get the following error:

Error occurred on line: 286 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:205)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod(Reflection.java:802)
at com.TriXar.Tech_Activities.main._activity_create(main.java:626)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:735)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:360)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at com.TriXar.Tech_Activities.main.afterFirstLayout(main.java:104)
at com.TriXar.Tech_Activities.main.access$000(main.java:17)
at com.TriXar.Tech_Activities.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6695)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:772)
** Activity (main) Resume **
You're not initializing your sql.

Walter
 
Upvote 0
Top