Hello, wen compiling this code is ok on emulator, and on real device give me an error and the app crash:
Error:
Seems that the "if then" Is not executed. (The table Is empty).Can help me ?
thanks in advance.
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("menuattrezzature")
Dim pathdb As String
pathdb=DBUtils.CopyDBFromAssets("rant.sqlite")
rant.Initialize(pathdb,"rant.sqlite",False)
Dim archivi As List
archivi.Initialize
archivi=DBUtils.ExecuteMemoryTable(rant,"SELECT id,tipologia,attrezzatura,descrizione,inventario,matricola,ubicazione FROM IMPIANTI ORDER BY TIPOLOGIA",Null,0)
Main.tipologia=""
B4XTree1.ItemHeight=100dip
B4XTree1.TextSize=10
If archivi.size > 0 Then
ToastMessageShow("sono qui",True)
Dim record() As String
For i= 0 To archivi.size-1
record=archivi.Get(i)
If Main.tipologia<>record(1) Then
Main.tipologia=record(1)
logo=Chr(0xf055)
B4XTree1.AddBranch(Main.tipologia,Main.tipologia,"",logo,Colors.Red)
End If
B4XTree1.BranchTextColor=Colors.White
index=record(0)
B4XTree1.AddLeaf(record(2) & CRLF & record(3) & "- " &record(6) & CRLF & "Inventario: " & record(4) & CRLF & "Matricola: " & record(5),"",index,Main.tipologia)
Log(record(0))
Log(record(1))
Log(record(2))
Log(record(3))
Log(record(4))
Log(record(5))
Log(record(6))
Next
End If
End Sub
Error:
B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at anywheresoftware.b4a.BA.addLogPrefix(BA.java:604)
at anywheresoftware.b4a.keywords.Common.LogImpl(Common.java:191)
at it.regant.app.menuattrezzature._b4xpage_created(menuattrezzature.java:109)
at it.regant.app.menuattrezzature.callSub(menuattrezzature.java:236)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1066)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037)
at it.regant.app.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:500)
at it.regant.app.b4xpagesmanager._showpage(b4xpagesmanager.java:802)
at it.regant.app.b4xpages._showpage(b4xpages.java:123)
at it.regant.app.b4xmainpage._btnattrezzature_click(b4xmainpage.java:70)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
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:7184)
at android.view.View.performClickInternal(View.java:7157)
at android.view.View.access$3500(View.java:821)
at android.view.View$PerformClick.run(View.java:27660)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7561)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
Seems that the "if then" Is not executed. (The table Is empty).Can help me ?
thanks in advance.
Last edited: