B4J Question Adding data fails

Jakob Micheelsen

Member
Licensed User
While adding 4001 pieces of data, something goes wrong and I can see what is wrong with the code
While adding the data to the list, each entry is correct. But as soon as last enry has is added, all entries are the same as the last one.

Can someone spot, what is wrong?

B4X:
Sub SaveDate
    Item.Initialize
    
    
    For i = 10000 To 14000
        Item.Clear
        Private iii As String
        iii=i
        Item.AddAll(Array As String (iii, AllinOne(i, 1), AllinOne(i, 2), AllinOne(i, 3), AllinOne(i, 4), AllinOne(i, 5), AllinOne(i, 6), AllinOne(i, 7)))
        All_Items.Add(Item)
'Here data is correct       
Log(All_Items.Get(i-10000))
    Next
'Here all 4001 entries in All_Items are the same as the last entry
Log(All_Items.Get(70))
    File.WriteList("C:\b4j\MakeList\Files\", "AllItems.txt", All_Items)
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
What is "item"?
I dont see you initialising a new Object of item in the Iterations. This is most probably the problem.
Upload a small project which shows the issue.
Or at least post a more complete code.
 
Upvote 0

xulihang

Active Member
Licensed User
Longtime User
the item is still referenced and will affect the all_items list. I don't know this until recently.
 
Upvote 0
Top