Search code examples
iphonedatabasecocoafilefmdb

FMDB databaseWithPath: not writing to disk


The fmdb docs say that if you pass a file system path to databaseWithPath: it will create a file for you:

  1. A file system path. The file does not have to exist on disk. If it does not exist, it is created for you.

I am getting my file system path with this code:

[[NSHomeDirectory() stringByAppendingPathComponent:@"Desktop"] stringByAppendingPathComponent:@"file.db"];

And attempting to setup my db like so:

FMDatabase *aDB = nil;

if (aLanguageDBPath) {
        aDB = [FMDatabase databaseWithPath:aLanguageDBPath];
}

The result is a valid FMDatabase object that isn't being written to disk as advertised. Did I misinterpret the explanation in the docs? How am I supposed to create and write dbs to disk on the fly?

Thanks!


Solution

  • Just found out that the db isn't actually made on disk until [db open]; is called.