如何在sqlite3数据库中存储图像

时间:2014-09-23 10:50:23

标签: ios iphone image sqlite xcode5

我有多个图片,我想将它存储在sqllite3的{​​{1}}数据库中。但是当我将其转换为blob格式时,它会显示一个存储在数据库中的大字符串。请告诉我如何解决这个问题,并建议我使用该特定方法的代码。我使用的代码是

xcode

无论如何压缩它。

1 个答案:

答案 0 :(得分:0)

{
sqlite3_stmt *statement = NULL;
int resultCode = 0;

if (sqlite3_prepare_v2([[ICSSSqliteManager sharedInstance] database], [mySQL cStringUsingEncoding: [NSString defaultCStringEncoding]] , -1, &statement, NULL) == SQLITE_OK){

    sqlite3_bind_blob(statement, 1, [data bytes], [data length], SQLITE_TRANSIENT);

    resultCode = sqlite3_step(statement);
    if (resultCode ==SQLITE_DONE) {
    }
    sqlite3_finalize(statement);

  }
 return resultCode;
}

Here data is image data