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 4053796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:29:34+00:00 2026-05-20T14:29:34+00:00

I got this far… here is my code: – (void)applicationDidFinishLaunching:(UIApplication *)application { // create

  • 0

I got this far… here is my code:

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
    //  create the d/b or get the connection value
    SQLiteDB *dbInstance = [[SQLiteDB alloc] init];
}

Now, the question is: this bit of code is supposed to check to see if a database exists, and if not, create it. My problem is I am having a problem figuring out exactly how to write the first line of the called method and where to place it in SQLiteDB.m. Is this an instance method (-) or a class method (+)?

I’m sorry for being so lame on this, but once I see it, I’ll have the hang of it… the rest of the code is written in C#, and I can handle the conversion to Obj_C.

  • 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-20T14:29:35+00:00Added an answer on May 20, 2026 at 2:29 pm

    The following is a method to copy an existing database from your Bundle to the Documents directory, but can easily be adapted for a new database. Just use the fileExistsAtPath: method logic below and replace the actions to take with your custom database creation code.

    Put this in your AppDelegate.m file:

    - (void)prepareDatabase
    {
        //add Database Versioning check to see if the resources database is newer
        // generally as simple as naming your database with a version on the end
    
        NSFileManager *filemanager = [NSFileManager defaultManager];
        NSString *databasePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingString:@"/YOURDATABASE.s3db"];
        if(![filemanager fileExistsAtPath:databasePath]) {
            //Database doesn't exist yet, so we copy it from our resources
            NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/YOURDATABASE.s3db"];
            if([filemanager copyItemAtPath:defaultDBPath toPath:databasePath error:nil]) {
                NSLog(@"Database Copied from resources");           
            } else {
                NSLog(@"Database copy FAILED from %@ to %@",defaultDBPath,databasePath);
            }
        }
    }
    

    Then in your applicationDidFinishLaunching: method call this:

    [self prepareDatabase];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got this line of code here but its not working. private void Button_Click(object sender,
Here is what I've got so far.. I'm using this as a keybind. I
I got this far: :~ curl -u username:password -d status=new_status http://twitter.com/statuses/update.xml Now, how can
I'm trying to implement a Haskell Bag (multiset). So far I've got this data
So this is as far as I got. Before I spend days throwing darts
I post this previously in Adobe Forum but haven't got any answers so far.
Got this code for a viewscroller from the apple developers site. @synthesize scrollView1, scrollView2;
I got this far: ProcessStartInfo procInfo = new ProcessStartInfo(@C:\a\a.exe); procInfo.CreateNoWindow = true; procInfo.Arguments =
I'm a beginner at setting up spring web-applications. I got this far but now
I am trying to rebuild this with pure css. And I've got this far.

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.