2017-07-22 47 views
-1

をブールに変換することができない私はsqliteのデータベースを更新しようとしているが、それはエラーを与えている:ここでSqliteをエラー:互換性のない型:intは

Error: Incompatible types: int cannot be converted to boolean

は私のコードです:

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文には赤で下線が引かれています。私の声明の問題は何ですか?私は何度も再チェックしましたが、何が間違っているのか分からないようです。

答えて

1
return _db.update(DATABASE_TABLE, values, KEY_ID + " = " + _rowIndex , null); 

db.update()方法は、コードの下に使用し、int型の値を返すとあなたのupdateEntryの戻り値の型を変更しません。

int returnValue= _db.update(DATABASE_TABLE, values, KEY_ID + " = " + _rowIndex , null); 
return returnValue==1 ? true : false; 
1

update()方法は、それが更新された行を提示整数を返すbooleanを返すので、int型

関連する問題