Hi All,
i'm trying to insert the url links in the SQLite3 database but its crashing does any one have any idea ... y its happening ?
if i statically trying to insert any url, it works but dynamically when i get urls of navigated web pages.... they do not insert.... please suggest me how to make it work. I'm using SDK 3.2
this is my insert function:
-(BOOL)insertImageToDB:(UIImage *)screenImage forURL:(NSString *)webURL
{
BOOL retValue=NO;
sqlite3 *database;
sqlite3_stmt *insert_statement = nil;
//NSString *localURL = webURL;
NSString *localURL = @"https://www.google.com/";
if (sqlite3_open([[self sqlitePath] UTF8String], &database)==SQLITE_OK)
{
const char *sql = "insert into Web_Image (Screen_Image, url) Values (?,?)";
if (sqlite3_prepare_v2(database, sql, -1, &insert_statement, NULL) == SQLITE_OK) {
NSData *data = UIImageJPEGRepresentation(screenImage, 0);
if(data != nil)
{
sqlite3_bind_blob(insert_statement, 1, [data bytes], [data length], SQLITE_TRANSIENT);
}
else
{
sqlite3_bind_blob(insert_statement, 1, nil, -1 , SQLITE_TRANSIENT);
}
sqlite3_bind_text(insert_statement, 2, [localURL UTF8String], -1, SQLITE_TRANSIENT);
//sqlite3_bind_text(insert_statement, 2, [webURL UTF8String], -1, SQLITE_TRANSIENT);
if(SQLITE_DONE == sqlite3_step(insert_statement)){
retValue=YES;
}
}
sqlite3_reset(insert_statement);
sqlite3_finalize(insert_statement);
sqlite3_close(database);
}
return retValue;
}
where, screenImage: is the current web page screenshot. webURL: is the url of the current web page.