已删除id的数据库更新

时间:2012-10-31 13:42:31

标签: android sqlite increment

有人可以告诉我下面的编码有什么问题。为什么我无法更新下一个职位?

     public static void deleteItemsFromProduct(long nomer) {

        cursor_child = DataSourceChild.queryAllinChild();

        if (cursor_child != null) {

            par = new String[]{String.valueOf(nomer)};

            db_child.delete(DBHelperChild.TABLE_ITEMS_AND_PRICES, DBHelperChild.COLUMN_NOMER + "=?", par);


Prod.setProdId(nomer);

cv_child = new ContentValues();
cv_child.put(DBHelperChild.COLUMN_NOMER, Prod.getProdId());

par = new String[]{String.valueOf(nomer+1)};

int updCount = db_child.update(DBHelperChild.TABLE_ITEMS_AND_PRICES, cv_child, DBHelperChild.COLUMN_NOMER + "=?", par);

Log.d(LOG_TAG, "updated rows count = " + updCount);

            if (cursor_child.moveToFirst()) {

                Log.d(LOG_TAG, "--- Left in the table for items and prices: ---");

                do {

                    Log.d(LOG_TAG,
                            "item id = " + cursor_child.getInt(item_and_price_idColIndex)
                            + ", item name = " + cursor_child.getString(item_ColIndex)
                            + ", item price = " + cursor_child.getInt(price_ColIndex)
                            + ", product nomer = " + cursor_child.getInt(nomer_ColIndex));

                } while (cursor_child.moveToNext());
            } else {
            }

        } else {
            Log.d(LOG_TAG, "Cursor is null");
            // закрываем курсор
            cursor_child.close();

        }
    }

这个想法是从另一个列表中获取id(nomer)时删除列表中的一组项目。此代码仅更新删除后的下一个id nomer,而不更新列表中的其他id nomer。 谢谢。

0 个答案:

没有答案