mardi 9 juin 2015

SQLite UPDATE statement updates all row in table

When adding a new row to my table, I check if the row already exist, if it does, I update the row else a new row is created. This works fine when I have only one row in my table. But when I add another row and perform the same operation, all the rows in the table are updated.

Am working with these test data:

Test 1

debtorName: Ann Droid
totalOwed = 200

and this is the result:

enter image description here

When I run the app again with the same test data, I get this result (as expected) enter image description here

Test 2

debtorName: Vera Brown
totalOwed: 700

I get the expected result, nothing changes in the first row: enter image description here

but when I try to update add a new record for the second row with this test data (or any other)

debtorName: Vera Brown
amountOwed: 200

this happens:

enter image description here

I've been trying to figure this out for the past 24 hours with no luck. I have two classes NewDebtFragment and DebtDatabaseHandler that handle this which are quite large so I'll add the code on pastebin. Any help is welcome.

Aucun commentaire:

Enregistrer un commentaire