android
2012-03-03 38 views 0 likes 
0

我發送bytearray插入一個blob元素它插入爲PNG圖像它工作。但我想刪除blob元素爲這些我發送bytearray列但它不會刪除。如何從sqlite android中的表中刪除blob元素?

public void deleteImage(Byte[] bytearray) 
{ 
    try{ 
    database.execSQL("DELETE FROM deleteImage "+" where image='"+bytearray+"';"); 
    } 
    catch(Exception e){ 
    e.toString(); 
    } 
    } 

回答

0

比較blob的時間比較昂貴,最好引入索引或校驗和並檢查它們。

When two BLOB values are compared, the result is determined using memcmp(). 
0

獲取圖像的ID,然後刪除該行

sqLiteDatabase.delete(TABLE_NAME, "_id=" + id, null); 

如果ü要更新另一個圖像,然後做更新操作。

String strFilter = "_id=" + idOfDbRow; 
ContentValues cv = new ContentValues(); 
cv.put("blob", blobfile); 
sqLiteDatabase.update(TABLE_NAME, cv, strFilter, null); 
相關問題