【问题标题】:When I'm retrieving blob value from SQLite it gives different value as it is stored in database当我从 SQLite 检索 blob 值时,它会给出不同的值,因为它存储在数据库中
【发布时间】:2012-07-29 05:56:31
【问题描述】:

当我从 SQLite 检索 blob 值时,它会给出不同的值,因为它存储在数据库中。我不知道为什么会这样。当我使用cursor.getString() 时,它给出了相同的值。但是当我使用curser.getBlob() 时,它给出了不同的价值。此外,当我使用getBytes()cursor.getString() 值转换为bytes[] 时,它再次转换为存储在数据库中的不同值。

请告诉我解决方案,因为我无法找到发生这种情况的原因。

【问题讨论】:

  • 发布您的代码以解决问题

标签: android database sqlite cursor blob


【解决方案1】:

我认为您已经使用插入查询将数据插入到 sqlite 数据库中。 在我看来,您应该使用以下方法插入数据以及图像。

CREATE TABLE IF NOT EXISTS " + DB_TABLE + "("+ 
               KEY_NAME + " TEXT," + 
               KEY_IMAGE + " BLOB);";

ContentValues cv = new  ContentValues();
cv.put(KEY_NAME,    name);
cv.put(KEY_IMAGE,   image);
database.insert( DB_TABLE, null, cv );

使用这个方法应该可以的。如果没有,请让我知道。 祝你好运。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-21
    • 2021-04-20
    • 1970-01-01
    • 1970-01-01
    • 2016-10-10
    • 2011-09-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多