I made a application for Ipad and it was working fine on simultor but when it installed on device for testing, database is not loading the value.
I am developing for the ios 4.3 target and I add the sqlite database file into supporting file folder and in Appdelegate file in add this code:
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self createDatabaseExecutableFile];
}
and the method code is
// Creates a writable copy of the bundled default database in the application Documents directory.
- (void) createDatabaseExecutableFile
{
// First, test for existence.
BOOL _success;
NSFileManager* _fileManager = [NSFileManager defaultManager];
NSError* _error;
NSArray* _paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* _documentsDirectory = [_paths objectAtIndex:0];
NSString* _writableDBPath = [_documentsDirectory stringByAppendingPathComponent:@"turfnutritiontool_ver_two.db"];
_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:@"turfnutritiontool_ver_two.db"];
_success = [_fileManager copyItemAtPath:defaultDBPath toPath:_writableDBPath error:&_error];
if (!_success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [_error localizedDescription]);
}
}
Well let me ask did you jail break your ios device …
any ways debug line by line and check whether
your _writableDBPath value and check whether db is on that location.
hope this will help you