从sqlitecipher db中删除斑点

发布于 2025-01-19 08:02:27 字数 939 浏览 3 评论 0原文

我将图像作为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文