1

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

     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(名称)。此代码仅在删除后更新下一个 id 名称,但不更新列表中的其他人。谢谢你。

4

0 回答 0