Android Question An error has occurred (java line 1749) index out of bounds exception invalid index size is 0

Makumbi

Well-Known Member
Licensed User
Please help find attached my simple project extracted from the big one when i try to delete selected row i get the above error
here is my json data that is generated after connect to the database
B4X:
[{"Account":"05-00001","sms":"We have sent him to the nurse please check","Datesent":"\/Date(1548257955000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"1","atk":9},{"Account":"05-00001","sms":"yes please","Datesent":"\/Date(1548363600000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"5","atk":13},{"Account":"05-00001","sms":"ok please sorry","Datesent":"\/Date(1548450000000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"1","atk":14},{"Account":"05-00001","sms":"ok please","Datesent":"\/Date(1548450000000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"1","atk":20},{"Account":"05-00001","sms":"ok too bad","Datesent":"\/Date(1548709200000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"3","atk":24},{"Account":"05-00001","sms":"ok teacher msg got","Datesent":"\/Date(1548882000000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"7","atk":25},{"Account":"05-00001","sms":"ok let me pick him","Datesent":"\/Date(1548277200000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"3","atk":10},{"Account":"05-00001","sms":"your child is too sick","Datesent":"\/Date(1548335760617)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"11","atk":11},{"Account":"05-00001","sms":"ok please","Datesent":"\/Date(1548450000000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"4","atk":17},{"Account":"05-00001","sms":"it is ending  tomorrow","Datesent":"\/Date(1548450000000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"2","atk":18},{"Account":"05-00001","sms":"please come and pick your child","Datesent":"\/Date(1548510500350)\/","Phone":"0782911364","Status":"New SMS","Type":"Father","Code":null,"atk":19},{"Account":"05-00001","sms":"next week please","Datesent":"\/Date(1548622800000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"2","atk":23},{"Account":"05-00001","sms":"he is good","Datesent":"\/Date(1548450000000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"2","atk":21},{"Account":"05-00001","sms":"ok teacher thank you","Datesent":"\/Date(1548536400000)\/","Phone":"0782911364","Status":"New Reply","Type":"Father","Code":"1","atk":22}]
 

Attachments

  • Screenshot_1548942325.png
    Screenshot_1548942325.png
    43.9 KB · Views: 300
  • Shipmyfile.zip
    10.1 KB · Views: 201

mangojack

Well-Known Member
Licensed User
Longtime User
There was no need to post the Json. It was not the cause of the Error msg.

Your uploaded project had a startup error ..
android.database.sqlite.SQLiteException: table Recievedsms has 4 columns but 3 values were supplied (code 1): , while compiling: INSERT INTO Recievedsms VALUES(?, ?, ?)

change
B4X:
Starter.SQL1.ExecNonQuery2("INSERT INTO Recievedsms VALUES(?, ?, ?)", Array As Object(DateTime.Date(ltt), quot.Get("sms"), quot.Get("Code")))

to ... (I have included the 4th parameter and "TEST NAME" to make it work
B4X:
Starter.SQL1.ExecNonQuery2("INSERT INTO Recievedsms VALUES(?, ?, ?,?)", Array As Object(DateTime.Date(ltt), quot.Get("sms"),"TEST NAME", quot.Get("Code")))



On the error you are wanting help on , Make the following change ..
B4X:
Sub ReadDataBaseIDs2
'............................................
'We read only the ID column and put them in a List
    If Starter.flagFilterActive = False Then
        cursor1 = Starter.SQL1.ExecQuery("SELECT ID FROM Recievedsms")'@@ Initially  ("SELECT ID FROM Sentmessages")
    Else
        cursor1 = Starter.SQL1.ExecQuery("SELECT ID FROM Recievedsms" & Starter.FilterQuery)    '@@ Inittially ("SELECT ID FROM Sentmessages" & Starter.FilterQuery)
    End If
'...........................................


I don't really understand the purpose of Sub/ s ReadDataBaseIDs (1 & 2) .. you iterate thru the DB and access the ID's in the Prior Subs 'Show Tables' already.

Also , many of the RecievedSMS's share the same ID's which I believe is nothing to do with the DB ID but a extracted Json Value.

You are attempting to delete DB record by extracting this ID from a Table_OverideURL Event ...
B4X:
values = Regex.Split("[.]", Url.SubString(7))
Url= http://1.9.stub/

A Table structure similar to SentSMS 's would be better ... Using the Auto Incremented ID as a reference

I also noticed you had 2 separate wbv_OverideURL Events ?
I have not had much dealings with WebView so unsure re Row clicks etc.

Personally .. I think using another display (xCustomListView for example) would allow you more control / interaction with displayed Data.

To finish ... I noticed your main app is quite large ..
Again personally, I would be concentrating on this stripped out version, working on the display, editing ,deletion of records until all errors are eliminated
and you are happy with the result

my two cents.... Cheers
 
Upvote 0
Top