I have done a similar thing with text files but i dont know how to do something like it using .sqlite.
Here is what i did for the text file
Code:
NSURL *webheight2 =[NSURL URLWithString: @"http://www.peteappdesigns.com/habscal/webheight2.txt"];
webHeight2 = [NSString stringWithContentsOfURL:webheight2 encoding:1 error:NULL];
NSString *webHeight2File = [documentsDirectory stringByAppendingPathComponent:@"webheight2.txt"];
[webHeight2 writeToFile:webHeight2File atomically:YES encoding:1 error:NULL];
how would i go about implementing something like this but with a .sqlite file.
I want to download the file to the documents directory and then it is used for the data of the tableview
here is where i would want to do this but instead of the local file it would be the internet file.
Code:
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"q1west.sqlite"];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success) return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"q1west.sqlite"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}