如何从源码Android的一个表中删除BLOB元素? [英] how to delete blob element from a table in sqlite android?
问题描述
我发送字节组,将其插入被插入的working.But我想删除一滴元素,这些我发送ByteArray的列png图片是一个BLOB元素,但它不会删除。
公共无效deleteImage(字节[]字节组)
{
尝试{
database.execSQL(DELETE FROM deleteImage+,其中图像='+字节组+;);
}
赶上(例外五){
e.toString();
}
}
试试这个(这为我的作品):
UUID存储为BLOB
db.execSQL(DELETE FROM+ DBHelper.USER_TABLE +WHERE+ DBHelper.USER_UUID +=?,
新的对象[] {uuidToByteArray(user.getUuid())}
文件:<一href=\"http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#execSQL%28java.lang.String,%20java.lang.Object[]%29\"相对=nofollow> SQLiteDatabase execSQL 。
据文档,字节[] ,字符串,长和Double在bindArgs支持。但是,不可以建议使用此方法执行SELECT / INSERT / UPDATE / DELETE语句。我不知道为什么。
公共无效execSQL(SQL字符串,对象[] bindArgs)
I am sending bytearray to insert an blob element it is inserting as png image it is working.But i want to delete blob element for these i am sending bytearray to column but it not deleting.
public void deleteImage(Byte[] bytearray)
{
try{
database.execSQL("DELETE FROM deleteImage "+" where image='"+bytearray+"';");
}
catch(Exception e){
e.toString();
}
}
Try this one (It works for me):
UUID is stored as BLOB
db.execSQL("DELETE FROM "+DBHelper.USER_TABLE+" WHERE "+DBHelper.USER_UUID+"=?",
new Object [] { uuidToByteArray(user.getUuid()) }
Documentation: SQLiteDatabase execSQL.
According to documentation, byte[], String, Long and Double are supported in bindArgs. However, it is not recommended to use this method for executing SELECT/INSERT/UPDATE/DELETE statements. I don't know why.
public void execSQL (String sql, Object[] bindArgs)
这篇关于如何从源码Android的一个表中删除BLOB元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!