I have a problem with a sqlite project that i'm doing, I'm using FMDB, I follow a simple example, but doesn´t work. And I can't find the error. I did my database schema from the terminal, I put some data on it. I'm very new to ios dev, so I don't know exactly if I did the steps ok. This is what I did:
1 - I made my Database schema and add some fields. 2 - I copied the database.db into my project folder in xcode. 3 - I add the FMDB files. 4 - I add the sqlite3.dylib 5 - I put this code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.dbname = @"database.db";
    NSArray * docPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString * docDIr = [docPath objectAtIndex:0];
    self.dbpath = [docDIr stringByAppendingPathComponent:dbname];
    [self checkDB];
    [self getQ];
    return YES;
}
-(void) getQ
{
    FMDatabase * db = [FMDatabase databaseWithPath:dbpath];
    [db open];
    FMResultSet * result = [db executeQuery:@"SELECT * FROM table1"];
    NSLog(@"last Error: %@",[db lastErrorMessage]);
    NSLog(@"result: %@", result);
}
-(void) checkDB
{
    BOOL success;
    NSFileManager * fm = [NSFileManager defaultManager];
    success = [fm fileExistsAtPath:dbpath];
    NSError * error = [[NSError alloc] init];
    if (success) return;
    NSLog(@"result:");
    NSString * dbPathFromApp = [[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:self.dbname];
    [fm copyItemAtPath:dbPathFromApp toPath:dbpath error:&error];           
}
Apparently the database it's empty, so what happened? why I can't find table1 ? If I open the file with any sqlite gui, the table appears just fine. Thank's for any help The console show me the next lines: 2013-03-02 14:03:31.839 myApp[21433:c07] last Error: no such table: table1 2013-03-02 14:03:31.841 myApp[21433:c07] result: (null)
 
    
 
     
    
 
    