I must add an existent DB into my apple iphone application I' ve attempted to place it in to the project's folder and used this init function

-(id) initDatabase{
    databaseName = @"mydatabase.sqlite";
    // Get the path to the documents directory and append the databaseName
 NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *documentsDir = [documentPaths objectAtIndex:0];
 databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
 [databasePath retain];

    return self;
}

after which i made use of this function

if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK){ //inserting methods

however i come with an error: the table 'nametable' doesn't is available, I am certain this table is available and i believe these techniques produce a new db file in to the device path HOW COULD I FIX THIS ISSUES? SORRY FOR MY BAD British!

Within the sidebar, check "Targets" => (Your Target) => "Copy Bundle Assets". I believe your database file might possibly not have been replicated because Xcode has no clue what file type that's.

You cannot have files within the documents folder to begin. Everything that accompany the application needs to be incorporated within the application bundle. The very first time the application runs, the documents folder is definitely empty.

You have to locate the file within the application bundle using NSBundle's pathForResource:ofType:.

When the DB is readonly, you can easily let it rest there. If it's readwrite, you have to copy the file in to the documents or library folder the very first time the application launches.


Update:

would you make a good example about using 'NSBundle's pathForResource:ofType:' please?I apologize but I am a new comer to apple iphone sdk

It is simply:

NSString *path=[[NSBundle mainBundle] pathForResource:@"myDatabase" ofType:@"sqlite"];