Android Sqlite错误:不兼容的类型:无法将int转换为boolean
我正在尝试更新sqlite中的数据库,但出现错误: 错误:不兼容的类型:int无法转换为boolean 这是我的密码:Android Sqlite错误:不兼容的类型:无法将int转换为boolean,android,sqlite,android-sqlite,Android,Sqlite,Android Sqlite,我正在尝试更新sqlite中的数据库,但出现错误: 错误:不兼容的类型:int无法转换为boolean 这是我的密码: public boolean updateEntry(long _rowIndex, String entryName, double entryTel, double entrySellp, int entryQty, String entrydate, int entryStaff, Context c) { ContentValues values
public boolean updateEntry(long _rowIndex, String entryName, double entryTel, double entrySellp, int entryQty, String entrydate, int entryStaff, Context c)
{
ContentValues values = new ContentValues();
values.put(ENTRY_NAME, entryName);
values.put(ENTRY_TEL, entryTel);
values.put(ENTRY_SELLINGPRICE, entrySellp);
values.put(ENTRY_QTYSOLD, entryQty);
values.put(ENTRY_DATESOLD, entrydate);
values.put(ENTRY_STAFFDISCOUNT, entryStaff);
// updating row
return _db.update(DATABASE_TABLE, values, KEY_ID + " = " + _rowIndex , null);
}
return语句用红色下划线。我的陈述有什么问题?我已经重新检查了很多次,但似乎无法找出问题所在。方法update()
不返回布尔值它返回一个表示更新行的整数,因此用int更改updateEntry
的返回类型
return _db.update(DATABASE_TABLE, values, KEY_ID + " = " + _rowIndex , null);
db.update()
方法返回int值,使用以下代码:
int returnValue= _db.update(DATABASE_TABLE, values, KEY_ID + " = " + _rowIndex , null);
return returnValue==1 ? true : false;