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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:12:14+00:00 2026-06-08T21:12:14+00:00

Again, I need someone’s help. I am following the below tutorial for SQLite connection

  • 0

Again, I need someone’s help. I am following the below tutorial for SQLite connection with FMDB wrapper:

http://www.icodeblog.com/2011/11/04/simple-sqlite-database-interaction-using-fmdb/

In the above tutorial, everything (creating a database and table, inserting, deleting) is done programmatically but everything works fine in simulator but when I use SQLite Manager add-on to make any insertion on the database (that was programmatically created in iOS), it doesn’t show up in my testing device. Is there something that I am missing (like copying the file to my bundle) on my side? This is really driving me crazy. I am completely new to these.. Can anyone help me with this?

PS: I know I can use Core Data but for certain reasons I have to live with SQLite for this app. Any help would be greatly appreciated.

Thank you in advance.

  • 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-08T21:12:16+00:00Added an answer on June 8, 2026 at 9:12 pm

    Make sure to (a) include the db in the bundle (see here for screen snapshot of where the “copy bundle resources” can be found); and (b) programmatically copy db from bundle to documents. You can then open it from there.

    Why it works on your simulator and not the device is a little curious. I can only imagine that you’re reading from some fixed path, rather than programmatically retrieving the app’s Documents folder?

    Update:

    I’d suggest checking your various return codes and make sure everything is ok.

    I’ve taken your code sample and have (a) checked result of creation of FMDatabase; (b) checked result of open; (c) checked the result of FMResultSet, including the display of the sqlite error message; and (d) closed the result set:

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docsPath = [paths objectAtIndex:0];
    NSString *path = [docsPath stringByAppendingPathComponent:@"DADatabase.sqlite"];
    
    FMDatabase *database = [FMDatabase databaseWithPath:path];
    NSAssert(database, @"Unable to create FMDatabase object");
    
    NSLog(@"%@", database);
    
    BOOL success = [database open];
    NSAssert(success, @"Unable to open database");
    
    FMResultSet *results = [database executeQuery:@"SELECT * FROM DrugList"];
    NSAssert(results, @"Unable to create result set: %@", [database lastErrorMessage]);
    
    while([results next]) {
        NSString *name = [results stringForColumn:@"Drugname"];
        [arrayToLoadDiseases addObject:name];
    }
    
    [results close]; 
    
    [database close];
    

    If you’re running this in your simulator, you can go ahead and inspect the simulator’s bundle and Documents folders if things don’t go right, just to make sure everything is where it should be. You simulator’s folder is something like “~/Library/Application Support/iPhone Simulator/5.1/Applications/” (replace the 5.1 with whatever version of your simulator you are using). You might have to unhide your Library folder, if you haven’t already, by running the chflags nohidden ~/Library in a Terminal command-line window. Anyway, you can open up the simulator’s database using Mac OS X’s sqlite3 command and make sure your table is ok.

    A common mistake is to fail to programmatically copy the database properly, thus the open method will create a blank database, and executeQuery will fail saying that the table was not found.

    Let me know what you find.

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

Sidebar

Related Questions

I again need help by you, this time I struggle with covariance, contravariance, delegates
Once again I need your Help, am thanking you as every time you helped
I need your help again :) I'm trying to do a plugin with jQuery
I need your help with this one again. I want to send special characters
Morning again..., Sorry to bother everyone but I need more help... I haven't done
I simply need to know if someone is following me on twitter, when they
I really need someone to help me to fully understand how to do many-to-many
I wonder if someone here can help me figure out this problem. I need
Once again I need some help. I'm working with a table that contains 3
I need a little help if someone's got a minute. I've written a web

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.