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

  • Home
  • SEARCH
  • 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 7822431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:55:22+00:00 2026-06-02T07:55:22+00:00

How to use sqlite database in iphone using xcode 4.3.2…. I am having problem

  • 0

How to use sqlite database in iphone using xcode 4.3.2….
I am having problem in finding path of my database ?? since i had copied FormDB.sqlite in Database folder in my app….Please help me as i am new to iphone programming…

calling this method in applicationDidFinishLaunching of Appdelegate file but it is returning success=false

- (void) copyDatabaseIfNeeded {

    //Using NSFileManager we can perform many file system operations.
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSError *error;
    NSString *dbPath = [self getDBPath];
    BOOL success = [fileManager fileExistsAtPath:dbPath]; 

    if(!success) {

        NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"FormDB.sqlite"];
        success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];

        if (!success) 
            NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
    }   
}

- (NSString *) getDBPath {

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
    NSString *documentsDir = [paths objectAtIndex:0];
    return [documentsDir stringByAppendingPathComponent:@"FormDB.sqlite"];
}
  • 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-06-02T07:55:24+00:00Added an answer on June 2, 2026 at 7:55 am

    In AppDelegate.h file declare

    @interface AppDelegate{
    
            NSString *databaseName;
        NSString *databasePath;
    
    }
    -(void) checkAndCreateDatabase;
    @end
    

    and then in

    @implementation AppDelegate{
    
        - (void)applicationDidFinishLaunching:(UIApplication *)application {
            // Setup some globals
            databaseName = @"FormDB.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];
    
            // Execute the "checkAndCreateDatabase" function
            [self checkAndCreateDatabase];
    
            // Query the database for all animal records and construct the "animals" array
            [self readAnimalsFromDatabase];
    
            // Configure and show the window
            [window addSubview:[navigationController view]];
            [window makeKeyAndVisible];
        }
        -(void) checkAndCreateDatabase{
            // Check if the SQL database has already been saved to the users phone, if not then copy it over
            BOOL success;
    
            // Create a FileManager object, we will use this to check the status
            // of the database and to copy it over if required
            NSFileManager *fileManager = [NSFileManager defaultManager];
    
            // Check if the database has already been created in the users filesystem
            success = [fileManager fileExistsAtPath:databasePath];
    
            // If the database already exists then return without doing anything
            if(success) return;
    
            // If not then proceed to copy the database from the application to the users filesystem
    
            // Get the path to the database in the application package
            NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];
    
            // Copy the database from the package to the users filesystem
            [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
    
            [fileManager release];
        }
    }
    @end
    

    try this code
    May this Help you….
    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using sqlite in an IPhone app for a readonly database. One use case
does it make sense to use an Filecache when using Sqlite as Database ?
i use sqlite database on my iphone app and i need to update this
I use an SQLite database on my iPhone application and i need to perform
In my iPhone app, I am importing CSV file into SQlite database using CHCSV
I'm currently developping a webapp for iphone which use the local sqlite database introduced
I am using sqlite database in my iphone app. I am writing code for
I've created a database for the iphone using sqlite and the fmdb wrapper. The
Still am using Coredata framework for iPhone applications. I want switch to use SQLite
I want to use SQLite update query to update the database in iPhone. Could

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.