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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:40:54+00:00 2026-05-25T13:40:54+00:00

I am working on an app that will be pulling data from a SQLite

  • 0

I am working on an app that will be pulling data from a SQLite Db locally. The app is running file but as I am testing, I add more records and such but for some reason both the simulator and the Device only see the last copy.

I have done a CLEAN build, removed the .DB from the project and then added it back, but to no avail. If the DB has 5 records, I update/add two more records, those new records are not showing.

About the only way I can get them to be seen is to remove the .DB from project, rename the DB to another name, then add back.

I know this sounds like some type of cache issue but am unable to figure out how to clear it out. As I mentioned, does same for both simulator and device.

Any help is greatly appreciated. Thanks in advance.

Geo…

  • 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-25T13:40:54+00:00Added an answer on May 25, 2026 at 1:40 pm

    If you have a db file in your resources, you need to copy it from resources to either library or document on launch and then connect to the one in documents or library.

    Hint: log out the path your connecting to, open that in terminal (it will be under Derived Data) and then connect and query using the sqlite3 cmd line (search). That helps keep you’re sanity that you’re operating on the right db and you can inspect your data as you go.

    As a side note, see this post (I have a library which handles all this if you’re interested):
    Don't wan't to replacing the old database when app is updated

    Here’s an example from a sample app where I call ensureOpened (which handles the copy from resource and logs what I’m using):

    - (BOOL)ensureDatabaseOpen: (NSError **)error
    {
        // already created db connection
        if (_contactDb != nil)
        {
            return YES;
        }
    
        NSLog(@">> ContactManager::ensureDatabaseOpen");    
        if (![self ensureDatabasePrepared:error])
        {
            return NO;
        }
    
        const char *dbpath = [_dbPath UTF8String]; 
        if (sqlite3_open(dbpath, &_contactDb) != SQLITE_OK &&
            error != nil)
        {
            *error = [[[NSError alloc] initWithDomain:@"ContactsManager" code:1000 userInfo:nil] autorelease];
            return NO;
        }
    
        NSLog(@"opened");
    
        return YES;
    }
    
    - (BOOL)ensureDatabasePrepared: (NSError **)error
    {
        // already prepared
        if ((_dbPath != nil) &&
            ([[NSFileManager defaultManager] fileExistsAtPath:_dbPath]))
        {
            return YES;
        }
    
        // db in main bundle - cant edit.  copy to library if !exist
        NSString *dbTemplatePath = [[NSBundle mainBundle] pathForResource:@"contacts" ofType:@"db"];
        NSLog(@"%@", dbTemplatePath);
    
        NSString *libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];
        _dbPath = [libraryPath stringByAppendingPathComponent:@"contacts.db"];
    
        NSLog(@"dbPath: %@", _dbPath);
    
        // copy db from template to library
        if (![[NSFileManager defaultManager] fileExistsAtPath:_dbPath])
        {
            NSLog(@"db not exists");
            NSError *error = nil;
            if (![[NSFileManager defaultManager] copyItemAtPath:dbTemplatePath toPath:_dbPath error:&error])
            {
                return NO;
            }
    
            NSLog(@"copied");
        }    
    
        return YES;    
    }
    

    Hope that helps

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

Sidebar

Related Questions

I'm working on an app that will provide data from a web server to
I'm working on an app that will both record an audio file, and then
I'm working on an app that will be using https, but we wanted to
I'm working on an app that requires no user input, but I don't want
I am working on an app that will need to handle very large numbers.
I'm working on creating an app that will parse MSDN articles for meta-information such
I'm working on an application that will run on Google App Engine. I would
I am working on an app that will use a custom keyboard for text
I am working on an app that will show the user the closest locations
I'm working on an app that will present surveys to the user. The markup

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.