从sqlitecipher db中删除斑点
我将图像作为 blob(byte[] 形式)存储在 SQLiteCipher 中:
public void insertNewImageBlob (byte[] image, String password) {
System.out.println(image);
SQLiteDatabase db = instance.getWritableDatabase(password);
ContentValues values = new ContentValues();
values.put(COLUMN_IMAGE, image);
db.insert(TABLE_NAME,null,values);
db.close();
}
该表没有任何内容,只有字节数组列表,没有 id 或任何内容。插入很好,RecyclerView 显示了数据库中的所有图像,现在用户单击图像,我想要删除该图像。因此,用户单击图像,然后我将图像发送到 deleteImage 方法以将其从数据库中删除。
这是尝试删除单个图像的代码:
public void deleteImage (String password, byte[] image) {
SQLiteDatabase db = instance.getWritableDatabase(password);
ContentValues values = new ContentValues();
values.put(COLUMN_IMAGE,image);
db.delete(TABLE_NAME,COLUMN_IMAGE+"='"+ image +"'",null);
db.close();
}
但它不会从数据库中删除图像。
I am storing images in SQLiteCipher as a blob (byte[] form):
public void insertNewImageBlob (byte[] image, String password) {
System.out.println(image);
SQLiteDatabase db = instance.getWritableDatabase(password);
ContentValues values = new ContentValues();
values.put(COLUMN_IMAGE, image);
db.insert(TABLE_NAME,null,values);
db.close();
}
The table has nothing just a list of byte array, no ids or anything. Insertion is good, RecyclerView shows all the images from the database, now then the user clicks on the image, i want the one to be deleted. So, user clicks an image and I send the image to deleteImage method to delete it from the database.
Here is the code trying me to Delete a single image:
public void deleteImage (String password, byte[] image) {
SQLiteDatabase db = instance.getWritableDatabase(password);
ContentValues values = new ContentValues();
values.put(COLUMN_IMAGE,image);
db.delete(TABLE_NAME,COLUMN_IMAGE+"='"+ image +"'",null);
db.close();
}
But it does not delete the image from the database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论