I looked a great deal in the search engines but unable to obtain the answer needed. I'm selecting photos in the image gallery and I wish to store it during my application. If I must store it in database(As BLOB), then I must go into the title from the file(which I'm not getting when i have selected in the gallery). Can One store it elsewhere? help. I'm stuck within this from the very long time. I have to extract the look and show it in map calloutview.

I'm while using below code to select photo from gallery and place in to the database

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)dictionary {
        [picker dismissModalViewControllerAnimated:YES];
    tempImg.image = image;
    NSData *imgData = UIImagePNGRepresentation(tempImg.image);
        NSLog(@"the img data %@",imgData);

sql = [NSString stringWithFormat:@"update latlng set image = '%@' where placeName = '%@'",imgData,pName.text];

The below code excuting the sql statement pointed out above

if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        const char *sqlStatement;
        sqlStatement = [sql UTF8String];;

        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) 
        {
            if (sqlite3_step(compiledStatement))
            {
                NSLog(@"YES");
            }
        }
        else 
        {
            printf( "could not prepare statemnt: %s\n", sqlite3_errmsg(database));
        }
        sqlite3_finalize(compiledStatement);

    }sqlite3_close(database);

The below code to extract from database

NSData *data = [[NSData alloc] initWithBytes:sqlite3_column_blob(compiledStatement, 5) length:sqlite3_column_bytes(compiledStatement, 5)];

the below code to show the look in callout

UIImageView *mapImg = [[UIImageView alloc] initWithImage [UIImageimageWithData:imgData]];
pinView.leftCalloutAccessoryView = mapImg;

Convert the look acquired for photo gallery to NSData after which save it in database like a Blob,So that you can easily retrieve the nsdata from database whenever you possessed.

NSData *image1Data = UIImagePNGRepresentation(image1.image);
sqlite3_bind_blob(init_statement, 1, [image1Data bytes], [image1Data length], NULL);

image1 may be the ImageView where i'm exhibiting the look in the photo gallery.

Best wishes.

This can be used to retrieve the road to a directory writable because of your application:

NSString *directory = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

You will find other ways to gain access to that directory, including NSData's writeToFile: techniques, the NSFileManager class, the NSFileHandle class, as well as C stdio functions.

During my situation i searching plenty of google after which finaly got solution that below code its work's for me personally i really hope its meet your needs

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{


NSLog(@"info: %@",info);

NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirec = [paths objectAtIndex:0];
NSString *imgePath = [documentsDirec stringByAppendingPathComponent:@"note.sqlite"];

if(sqlite3_open([imgePath UTF8String], &database) == SQLITE_OK){

    const char *sql = "insert into images (images) values (?)";
    if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) == SQLITE_OK){
        UIImage *edtedImae = [info objectForKey:UIImagePickerControllerOriginalImage];
        NSData *dataForImage = UIImagePNGRepresentation(edtedImae);
        sqlite3_bind_blob(addStmt, 1, [dataForImage bytes], [dataForImage length], SQLITE_TRANSIENT);
    }
    if(sqlite3_step(addStmt) != SQLITE_DONE){

        NSLog(@"error %s",sqlite3_errmsg(database));
    }
    else {
        NSLog(@"Insert row Id = %d",sqlite3_last_insert_rowid(database));
    }
    sqlite3_finalize(addStmt);

    }
   sqlite3_close(database);               
   [picker dismissModalViewControllerAnimated:YES];
}

thanks