I am using photos saved in photo library in my application. how can I retrieve path of photos saved in photo library?
I had converted that UIImage
into NSData
and saved that data in application's sandbox(in one file).Using sqlite , I have created a database and saving file path in database.
Whenever i need image, I retrieve NSData
from file path saved in database.
NSMutableData *data=[[NSMutableData alloc]init];
data =UIImagePNGRepresentation([UIImageimageNamed:@"image.png"]);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"first.txt"]; [data writeToFile:filePath atomically:YES];
NSString *m=[[@"'"stringByAppendingFormat:filePath]stringByAppendingFormat:@"'"];
NSString *query=[[@"INSERT INTO newtable (image) VALUES (" stringByAppendingFormat:m]stringByAppendingFormat:@")"];
NSLog(@"query....%@",query);
[obj configureDatabase:@"Editerdb.rdb"];//function to configure database
[obj insertInTable:query];// function to insert into db
This code is working. Is there any simple way to do that?