View Full Version : not open SQLite database in iPhone device
diyora
Sep 17, 2008, 01:00 AM
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..
PhoneyDeveloper
Sep 17, 2008, 07:54 AM
How do you get the path to the db? Show your code for opening the db that is failing.
arme
Sep 28, 2008, 05:32 AM
How do you get the path to the db? Show your code for opening the db that is failing.
HI
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.
PhoneyDeveloper
Sep 28, 2008, 08:42 AM
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.
annguyen
Oct 2, 2008, 07:38 AM
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..
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];
:apple:
robbieduncan
Oct 2, 2008, 07:56 AM
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: ...code snipped...
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: (http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingPathComponent:) which automatically deals with missing / characters.
PhoneyDeveloper
Oct 2, 2008, 10:22 AM
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.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.