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

skunkio

macrumors newbie
Original poster
Hi all,
i'm testing for the first time my app on my touch...i'm so excited!!! 😀

Anyway, something is not working properly and i receive an error when my app tries to open a db file.
Inside my code i check if a db file exsists within my app folder.
Using the row below i create the path file i suppose to be used by my app

Code:
DB_NAME = [[NSString alloc] initWithFormat:@"%@/%@", NSHomeDirectory(), @"test.db"];

and this is the result:

/var/mobile/Applications/DAA06493-CAA9-475F-AFB6-D5257C9BD566/test.db

then with a simple cicle i check if this file exists in my app folder (always in NSHomeDirectory()).
If it's not there i run some sql to set my db properly. I use code below to open a connecion

Code:
const char *dbName = [database UTF8String];
dbrc = sqlite3_open(dbName, &db);
	
if (dbrc) {
        NSLog (@"couldn't open db: %@ (error number: %i)", database, dbrc);		
	return FALSE;
}

and i receive the following error

couldn't open db: /var/mobile/Applications/5DCA12D5-7FD4-4643-A63A-D60A0193DFE4/test.db (error number: 14)

Infact error number is clear, from sqlite result codes


#define SQLITE_CANTOPEN 14 /* Unable to open the database file */


Can i create e file in this folder?

/var/mobile/Applications/DAA06493-CAA9-475F-AFB6-D5257C9BD566


Moreover, i see the long name after Applications changing every time i switch on my ipod and run my app.
Where i should save my db file over my iPod and be sure to use the same path when i switch on my ipod again?


Ciao,
stè
 
Solved the issue, seems i can't write directly in my app root folder but i can in the Documents folder.
I changed my code creating my db file there and now it works (i changed also the way to identify my app folder but this is not the main problem).


Ciao,
stè
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.