views:

163

answers:

1

Why would this run fine on the iPhone simulator... but the database can't be opened on an iPhone device?

sqlite3 *g_Db = nil;

BOOL OpenDatabase(NSString *databaseName)
{
    if(sqlite3_open([databaseName UTF8String], &g_Db) == SQLITE_OK)
    {
        NSLog(@"Opened db ok");
        return(YES);
    }
    else
    {
        NSLog(@"Can't open the db");
        sqlite3_close(g_Db);
        g_Db = nil;
        return(NO);
    }
}
+1  A: 

If the database doesn't exist yet and you are using SQLite's ability to create the database on first reference, then the file path has to point to the iPhone's document directory (or tmp) since you can write to the application bundle directory in the simulator but not on the device due to permissions. That's the only thing which jumps out at me as obviously different between the two which would effect SQLite code.

Devin Ceartas
Ugh... I forgot about that. Let me check... but I bet that's it.
Susanna