Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-16-2010, 11:00 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 5
Skyman is on a distinguished road
Default Sqlite3 - working on simulator but not on device

Hey Everyone,

I'm completely stuck, my app works just fine on the iphone simulator but when i try to run it on my ipod touch the database doesn't work.

I've confirmed that the file name is spell correctly. in fact I added AlertViews to see what exact path i wass using on both simulator and on the device. I know that simulator isn't case sensitive and the device is... but I can't see any spelling mistakes.

simulator :

Users/*********/Library/Application Support/iPhone Simulator/4.0/Aplications/*****-*****-****-****/Documents/data.sqlite3

device :

/var/mobile/Applications/********-****-****-****-********/Documents/data.sqlite3

I have no clue where to look.
Skyman is offline   Reply With Quote
Old 07-16-2010, 11:06 AM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 916
lukeca is on a distinguished road
Default

How are you getting that database to the documents folder in the first place?
lukeca is offline   Reply With Quote
Old 07-16-2010, 01:42 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 5
Skyman is on a distinguished road
Default

EDIT: I thought xcode would put the database there when I compile it? doesn't it?

The code to retreive the path is like this:

-(NSString *)dataFilePath
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:kFileName];
}

Where kFileName is:

#define kFileName @"data.sqlite3"



It might be worth mentioning that I first noticed the problem after upgrading to sdk 4.0. I dunno
Skyman is offline   Reply With Quote
Old 07-16-2010, 01:53 PM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 916
lukeca is on a distinguished road
Default

Well because of the sandboxing that is present on the actual device you have to copy the database out of the app bundle and into the documents directory the first time you run the app.

Take a read through this tutorial, it explains what you need to do pretty well:
iPhone Programming Tutorial – Creating a ToDo List Using SQLite Part 1 | iCodeBlog
lukeca is offline   Reply With Quote
Old 07-16-2010, 03:44 PM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 5
Skyman is on a distinguished road
Default

Thanks for the quick reply. I'm going to try this out and message about the results tommorow. Though right now my code looks very similar to the example.
Skyman is offline   Reply With Quote
Old 07-16-2010, 04:23 PM   #6 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 541
chaseacton is on a distinguished road
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Default

Quote:
Originally Posted by Skyman View Post
Thanks for the quick reply. I'm going to try this out and message about the results tommorow. Though right now my code looks very similar to the example.
Do a Build --> Clean All and see if maybe its a caching problem on the device.
__________________
Freelance Inquiries:
www.chaseacton.com/services

Apps:
chaseacton is offline   Reply With Quote
Old 07-18-2010, 09:42 AM   #7 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 5
Skyman is on a distinguished road
Default

I'm embarrassed to say the solution was very very simple. I did not have the database properly imported into my project. So it was positioned correctly to compile for simulator but not when I compile it for my ipod touch device.

Thanks for all the help, and for the link to the guide.
Skyman is offline   Reply With Quote
Reply

Bookmarks

Tags
database, device, simulator, sql, sqlite3

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 335
15 members and 320 guests
akphyo, alexP, appservice, cgokey, EXOPTENDAELAX, flamingliquid, guusleijsten, mariano_donati, ohmniac, Paul Slocum, PavelSea, Rudy, SLIC, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:39 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0