Android Question Why Map Overwrite the First Value?

Pravee7094

Active Member
Hi all,
I have a one table. In this table there is one field called "Barcode". I just add two barcodes Named as (S1234, S7890) in the table.
Now I want to read all the data from table and store to database.
Here is the sample coding.

B4X:
    Dim ll_list As List
    ll_list.Initialize
    Dim lm_map As Map
    lm_map.Initialize
    
    For i = 0 To if_flexgrid_table.RowCount - 1
        Dim RowData As List = if_flexgrid_table.GetCellRow(i)
        
        lm_map.Put("barcode_detail", RowData.Get(0))

        ll_list.Add(lm_map)
    Next
    
    Log("Result : " & ll_list)

Result:
B4X:
Result : (ArrayList) [{barcode_detail=S7890}, {barcode_detail=S7890}]

I just Want two data one by one. Here, Second barcode overwrite the first barcode.
How can I get two barcodes one by one?

Expected Result:
B4X:
Result : (ArrayList) [{barcode_detail=S1234}, {barcode_detail=S7890}]
Any suggestions or Help?

Thanks
 

udg

Expert
Licensed User
Longtime User
Move
B4X:
Dim lm_map As Map
lm_map.Initialize
inside the loop
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Wouldn't it be enough to move this into the loop?
No. It would fail to create a new map. It would only initialize the existing map
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Upvote 0
Top