hello, i have one app with SQL lite database, in this app i use this class: CameraExClass, FileProvider, ExternalStorage, QrGenerator,
if save one element in edittext with this metod:
, i recevie this error
main_btnaddcliente_click (java line: 1124)
java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteStatement android.database.sqlite.SQLiteDatabase.compileStatement(java.lang.String)' on a null object reference
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at com.partannasoftware.LePre2020.main._btnaddcliente_click(main.java:1124)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7870)
at android.widget.TextView.performClick(TextView.java:14970)
at android.view.View.performClickInternal(View.java:7839)
at android.view.View.access$3600(View.java:886)
at android.view.View$PerformClick.run(View.java:29363)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7948)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
this is the button complete for saving the element in database:
if save one element in edittext with this metod:
B4X:
dbsql.ExecNonQuery2("INSERT INTO field1 VALUES (?)", Array As String(txtcaricaporodotto.Text & " - " & "Euro" & " " & txtcaricoeuro.Text))
, i recevie this error
main_btnaddcliente_click (java line: 1124)
java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteStatement android.database.sqlite.SQLiteDatabase.compileStatement(java.lang.String)' on a null object reference
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at com.partannasoftware.LePre2020.main._btnaddcliente_click(main.java:1124)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7870)
at android.widget.TextView.performClick(TextView.java:14970)
at android.view.View.performClickInternal(View.java:7839)
at android.view.View.access$3600(View.java:886)
at android.view.View$PerformClick.run(View.java:29363)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7948)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
this is the button complete for saving the element in database:
B4X:
Sub btnpiu_Click
If txtcaricoeuro.Text="" Then
MsgboxAsync("inset element before save","ALERT !!")
Else
If txtcaricoeuro.Text.Contains(",") = True Then
txtcaricoeuro.Text.Replace(",",".")
End If
If txtcaricaporodotto.Text="" Then
MsgboxAsync("insert element before save","ALERT !!")
Else
dbsql.ExecNonQuery2("INSERT INTO field1 VALUES (?)", Array As String(txtcaricaporodotto.Text & " - " & "Euro" & " " & txtcaricoeuro.Text)) ' when in debug in this line i have the error
spm1.Add (txtcaricaporodotto.Text & " " & "Euro" & " " & txtcaricoeuro.Text) '
txtcaricoeuro.Text="" '
dbcursor.Close
MsgboxAsync("Element added","DONE")
txtcaricaporodotto.Text=""
End If
End If
ps1.HideKeyboard(Activity)
txtcaricoeuro.Text=0
End Sub