Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

diyora

macrumors newbie
Original poster
Jul 21, 2008
25
0
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

macrumors 68040
Sep 2, 2008
3,114
93
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

macrumors newbie
Oct 2, 2008
15
0
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:

Code:
//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

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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: which automatically deals with missing / characters.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.