store and retrieve security scoped bookmarks in SQLite DB

Can I store and retrieve ‘security scoped bookmarks’ in a Sqlite db ?
Can anyone set me on the right track on how to do it ?

A security-scopedbookmark is just a blob of data, so you’d store it like any other blob of data.

Thank you.

I use already this kind of code to create tables in my SQLite db.
How to define “Blob” type fields ?

  • (void) createTableNamed:(NSString *) tableName
    withField0:(NSString *) field0
    withField1:(NSString *) field1
    {
    char *err;
    NSString *sql = [NSString stringWithFormat:@“Create table if not exists ‘%@’ (ID INTEGER PRIMARY KEY AUTOINCREMENT, ‘%@’ Text, ‘%@’ Text, ‘%@’ Text);”, tableName, field0, field1];
    if (sqlite3_exec(myDb, [sql UTF8String], NULL, NULL, &err) != SQLITE_OK){
    sqlite3_close(myDb);
    NSAssert(0, @“Table failed to create.”);
    }
    }

Hi,

security scoped bookmarks are NSData objects.
To store the data in a widely text based database you could get a textual representation by Base-64 encoding.

The methods of NSData are

encoding : -(NSString *)base64EncodedStringWithOptions:
decoding : -(instancetype)initWithBase64EncodedString:options:

Stefan, Shane thank you for the help !

finally I did the conversion of the NSData to NSString and uploaded it afterward to my SQLite DB

//NSData to NSString
-(NSString*)hConvertNSdToNSstr:(NSData*)myData{
return [myData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
}

//NSString to NSData
-(NSData*)hConvertNSstrToNSd:(NSString*)myString{
return [[NSData alloc]initWithBase64EncodedString:myString options:NSDataBase64DecodingIgnoreUnknownCharacters];

}