Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3444506
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:55:26+00:00 2026-05-18T08:55:26+00:00

I have to add an existent DB into my iphone app I’ ve tried

  • 0

I have to add an existent DB into my iphone app
I’ ve tried to put it into 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;
}

and then i used this function

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

but I have an error: the table ‘nametable’ does not exists, I am sure that this table exists and I think that these methods create a new db file into the device path.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:55:27+00:00Added an answer on May 18, 2026 at 8:55 am

    You can’t have any files in the documents folder to start. Everything that comes with the app has to be included in the app bundle. The first time the app runs, the documents folder is always empty.

    You need to locate the file inside the app bundle using NSBundle’s pathForResource:ofType:.

    If the DB is readonly, you can just leave it there. If it is readwrite, you need to copy the file into the documents or library folder the first time the app launches.


    Update:

    could you make an example about using
    ‘NSBundle’s pathForResource:ofType:’
    please?I’m sorry but I’m new to iphone
    sdk

    It’s just:

    NSString *path=[[NSBundle mainBundle] pathForResource:@"myDatabase" ofType:@"sqlite"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my rails app,I have add a alias path at apache httpd.conf like this:
I have an add this button on the website that is rendering a border
I have several places on the page where there is text Add This text
In one of my iOS project I have add a sub-module added, lets say
I have a link like http://www.myweb.it/people/add/ when execute I have problem about non-existent add
I've put together a function that creates a sharepoint folder in a document library
I have an autotools-managed project ( sscce tar.gz package here ) with this structure:
I have add another language to my app. So, I am using the following
I have to add a custom layout in a relative layout on a button
I have to add a column whose default value is not null by default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.