not open SQLite database in iPhone device

Discussion in 'iOS Programming' started by diyora, Sep 16, 2008.

  1. diyora macrumors newbie

    Jul 21, 2008
    Hello all,
    I used SQLite database.It is open when i run code in iPhone simulator mode.
    But when i run same code on iPhone device mode it is not open or it is not found come.

    Thank you..
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    How do you get the path to the db? Show your code for opening the db that is failing.
  3. arme macrumors member

    Sep 15, 2008
    i use SQLite in my project but the compiler don't know functions of sqlite3?
    i including sqlite3.h in my app. but don't work.
  4. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    Look at the SGLiteBooks sample code for an example that works. Obviously you're either missing the header file or the library from your project.
  5. annguyen macrumors newbie

    Oct 2, 2008
    It worked on simulator but not the device? I used to face this problem before. Probably the document directory doesn't end with the "/" character. Check to append "/" to end of the document directory before joining with the DB file name.

    Something like this:

    //Get the first path in the array.
    	NSString *documentsDirectory = [paths objectAtIndex:0];
    	if (![documentsDirectory hasSuffix:@"/"]) {
    		documentsDirectory = [documentsDirectory stringByAppendingString:@"/"];
    	//Create the complete path to the database file.
    	NSString *databasePath = [documentsDirectory stringByAppendingString:DB_FILENAME];
  6. robbieduncan Moderator emeritus


    Jul 24, 2002
    Whilst I have no doubt that would work you would be much better using the provided NSString path utilities that do all the work for you. I'd recommend stringByAppendingPathComponent: which automatically deals with missing / characters.
  7. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    One other thing: the iPhone file system is case sensitive but the Mac file system is case insensitive. Code that works on the simulator will fail on the device if the case isn't correct.

Share This Page