execSQL() with UPDATE doesn't update

后端 未结 2 1265
Happy的楠姐
Happy的楠姐 2020-12-21 08:30

I am trying to use rawQuery and execSQL methods for manipulating my database, instead of the .update, .insert, etc. I am

2条回答
  •  醉话见心
    2020-12-21 09:16

    here is an sample update Query:

    public boolean updateCartTable(String retailerName, String mCouponId){
            final ContentValues values = new ContentValues();
    
            values.put(TableConstantName.COUPON_ONLY_STATUS, 1);
            values.put(TableConstantName.COUPON_SRORE_DEALS_STATUS, 1);
            values.put(TableConstantName.COUPON_CATAGORY, "C");
            try {
                sDb.beginTransaction();
                final boolean state = sDb.update(TableConstantName.COUPON_TABLE, values, TableConstantName.CART_COUPON_RETAILER_NAME + "=" + "'"+retailerName+"'"+ " AND "+TableConstantName.CART_COUPON_ID + "=" + "'"+mCouponId+"'", null)>0;
                sDb.setTransactionSuccessful();
                return state;
            } catch (SQLException e) {
                throw e;
            } finally {
                sDb.endTransaction();
            }
        }
    

提交回复
热议问题