R ronovar Active Member Licensed User Longtime User Sep 13, 2018 #1 I have string array in my apk that works great up to 4999 items, and when i get 5000 item it get's this error: Code: Copy java.lang.ArrayIndexOutOfBoundsException: length=5000; index=-1 So up to 4999 items it works great without error message, but when 5000 item is comming to be read into array i get above message. I have 6000 items to be filled into array so need solution how to put these items into string array (plan is 10 000 items in feauture). Here is the code that gives me this error: Code: Copy 'REDEFINE - Arrays Dim MovieInfo(Menu.VideoClubList.Size, 13) As String So as you can see i im reinitializing existing array that have 13 items and it's size is defined in Menu.VideoClubList.Size that have size of 6000 items. You can try in your program to initialize array and try to fill 6000 items into that array and you will get error...i think that String could not handle more that 4999 items if i im right so need another solutio how to fix this. So try this in attached program. Attachments test.zip test.zip 6.7 KB · Views: 541
I have string array in my apk that works great up to 4999 items, and when i get 5000 item it get's this error: Code: Copy java.lang.ArrayIndexOutOfBoundsException: length=5000; index=-1 So up to 4999 items it works great without error message, but when 5000 item is comming to be read into array i get above message. I have 6000 items to be filled into array so need solution how to put these items into string array (plan is 10 000 items in feauture). Here is the code that gives me this error: Code: Copy 'REDEFINE - Arrays Dim MovieInfo(Menu.VideoClubList.Size, 13) As String So as you can see i im reinitializing existing array that have 13 items and it's size is defined in Menu.VideoClubList.Size that have size of 6000 items. You can try in your program to initialize array and try to fill 6000 items into that array and you will get error...i think that String could not handle more that 4999 items if i im right so need another solutio how to fix this. So try this in attached program.
Erel B4X founder Staff member Licensed User Longtime User Sep 13, 2018 #2 You are not redefining the array. You are creating a two dimensions array with the second rank set to 0. ronovar said: i think that String could not handle more that 4999 items if i im right so need another solutio how to fix this. Click to expand... You are wrong. There is no limit except of the available memory. Example of an array with million items: Code: Copy Dim MillionMovies (1000000) As String For i = 0 To MillionMovies.Length - 1 MillionMovies(i) = "a" Next Log(MillionMovies.Length) The correct solution however is to use a List instead of an array. It is explained in the video tutorials. Upvote 0
You are not redefining the array. You are creating a two dimensions array with the second rank set to 0. ronovar said: i think that String could not handle more that 4999 items if i im right so need another solutio how to fix this. Click to expand... You are wrong. There is no limit except of the available memory. Example of an array with million items: Code: Copy Dim MillionMovies (1000000) As String For i = 0 To MillionMovies.Length - 1 MillionMovies(i) = "a" Next Log(MillionMovies.Length) The correct solution however is to use a List instead of an array. It is explained in the video tutorials.
R ronovar Active Member Licensed User Longtime User Sep 13, 2018 #3 Ok..thanks..i got now to use list..could you please write me code how to define 2d list? I could not find it in your tutorial...so how to define 2d list like this array: Code: Copy Dim MovieInfo(Menu.VideoClubList.Size, 13) As String And how then to put word "a" into that 2d list? Thanks. Upvote 0
Ok..thanks..i got now to use list..could you please write me code how to define 2d list? I could not find it in your tutorial...so how to define 2d list like this array: Code: Copy Dim MovieInfo(Menu.VideoClubList.Size, 13) As String And how then to put word "a" into that 2d list? Thanks.
Erel B4X founder Staff member Licensed User Longtime User Sep 13, 2018 #4 List is a dynamic single dimension array. You can put any items you like inside the lists including other arrays or lists. Upvote 0
List is a dynamic single dimension array. You can put any items you like inside the lists including other arrays or lists.