mercredi 16 juin 2021

How to fix While Cursor loop Not Working?

I need your help for this coding, I wanted to fix this coding, because this isn't working for my database, the problem is :

Cursor cursor = db.countCart();
while(cursor.moveToNext()) {
    if(cursor.getInt(1) != 1) {
        db.updateIntoCart(1);
    } else if(cursor.getInt(0) == 1){
        db.insertIntoCart(1);
    }
}

countCart() is viewing database were using 3 column, the second column is foreign key id of product.

I mean with this code is if product id exist, then only do update, but if product id doesn't so do insert.

Thanks guys for your answer

Aucun commentaire:

Enregistrer un commentaire