Android Question ListView duplicating records

MarcioCC

Member
Licensed User
Longtime User
Good night friends, I have a problem that I am not able to solve I am developing a data collector app using a listview to add the scanned bar codes only the codes are duplicating in my listview follows the image of the duplicate codes, Code where I add the records in the listview.
Has anyone ever experienced this??

Code:

If Edtdescr.Text<>"" Then

s.ExecNonQuery2("INSERT INTO PRODUTOS (rowid,CODBARRAS,QUANTIDADE) VALUES (NULL,?,?)", Array As String(Edtdescr.Text,EdtQtde.Text))



c=s.ExecQuery("SELECT CODBARRAS,QUANTIDADE FROM PRODUTOS ORDER BY CODBARRAS")



If c.RowCount>0 Then
For i=0 To c.RowCount -1
c.Position=i


Lvadiciona.AddTwoLinesAndBitmap(C.GetString ("CODBARRAS"), C.GetString ("QUANTIDADE"),LoadBitmap(File.DirAssets,"ICONE LIXEIRA2.jpg"))





Next

End If
End If



ToastMessageShow("Leitura do código correto.",False)
 

Attachments

  • Duplicating records.jpg
    Duplicating records.jpg
    133.4 KB · Views: 227

Ed Brown

Active Member
Licensed User
Longtime User
Looking at the code provided the first thing I would check is that the database table is empty. There may already be rows in the table and you are adding new rows each time.
 
Upvote 0

Ed Brown

Active Member
Licensed User
Longtime User
What I'm saying is that you may have duplicate records in your database. Check your database.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi,
try to insert right before the For loop the following line
B4X:
Lvadiciona.Clear

ps: you are not calling the read-all-records SELECT after each insert operation, right?
 
Upvote 0

MarcioCC

Member
Licensed User
Longtime User
Problem solved friend I used the Lvadiciona.Clear before loop and it worked cool.
Thank you !!
 
Upvote 0
Top