views:

115

answers:

1

hello i want to replace my sqlite DB stores on iphone by a sqlite which is on my server for an update. how could i do that? i can download it and get it with an NSData object but how do i store it on the iphone and then replace the old one ? thanks

A: 

That's pretty simple. It should just be something like this:

NSData *fetchedData = ...;    /* downloaded using NSURLConnection or whatever*/
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"DBName.sqlite"];

[fetchedData writeToFile:filePath atomically:YES];
Sbrocket