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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:48:12+00:00 2026-05-18T23:48:12+00:00

My problem appears in the device but not in the simulator. nDBres=sqlite3_prepare_v2(databaseConn, sqlStatement, -1,

  • 0

My problem appears in the device but not in the simulator.

nDBres=sqlite3_prepare_v2(databaseConn, sqlStatement, -1, &compiledStatement,NULL)

It’s an insert query that I’m trying to run. In the simulator it returns 0, whereas in the device it returns 8. After this whenever I try to run any other write operation, the app crashes.

I’m going nuts over this.

  • 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-18T23:48:13+00:00Added an answer on May 18, 2026 at 11:48 pm

    You can consult the list of sqlite3 error codes as part of the sqlite3 API documentation (http://www.sqlite.org/c3ref/c_abort.html. Error code 8 is SQLITE_READONLY (“Attempt to write a readonly database”).

    As you probably know, iOS sandboxes applications running on the device, so you must make sure to create your database in one of the areas that the OS exposes for creating application writable files.

    There’s a decent tutorial on how to set up a sqlite3 project on iOS http://icodeblog.com/2008/08/19/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-1/.

    From that tutorial, the most important part for your issue is probably the createEditableCopyOfDatabaseIfNeeded method in the app delegate. This illustrates how you can ensure that you create an editable database file when your app launches for the first time:

    (Note, this isn’t my code… I’m reproducing it from the tutorial on icodeblog.com, where they explain it in detail)

    - (void)applicationDidFinishLaunching:(UIApplication *)application {
        [self createEditableCopyOfDatabaseIfNeeded];
        [self initializeDatabase];
    
        // Configure and show the window
        [window addSubview:[navigationController view]];
        [window makeKeyAndVisible];
    }
    
    // Creates a writable copy of the bundled default database in the application Documents directory.
    - (void)createEditableCopyOfDatabaseIfNeeded {
        // First, test for existence.
        BOOL success;
    
        NSFileManager *fileManager = [NSFileManager defaultManager];
        NSError *error;
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"todo.sqlite"];
        success = [fileManager fileExistsAtPath:writableDBPath];
    
        if (success) return;
    
        // The writable database does not exist, so copy the default to the appropriate location.
        NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"todo.sqlite"];
        success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
        if (!success) {
            NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem appears to be intermittent, but I am not sure why exactly. When
I'm working on a simple carousel. My problem appears when trying to insert node
I've exhausted all efforts at what appears to be a trivial problem, but gotten
I'm not really sure where my problem is but the scenario is as follows.
On the simulator I see the UIMenucontroller without a problem but it won't appear
This problem appears similar to other posts, it is not the same as any
Update : The problem appears to have been corrupt DLLs somewhere in my PHP
I have this mysql tables I want to display with jqgrid. The problem appears
I have a problem that appears and disappears for mysterious reasons. A while back
semi Resolved It appears that the problem exists only when running in debug mode,

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.