iOS 5.1 cant find sqlite file

496 views Asked by At

I'm having some trouble finding my sqlite file. When I run de app with iOS 5 simulator it runs ok but when I run it on iOS 5.1 it can't find the sqlite file. I'm using this code to find the file.

- (NSString *) getDatabasePath {
    NSString* databaseName = @"bohn_db.bin.sqlite";
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
    return [documentsDir stringByAppendingPathComponent:databaseName];      
}

On iOS 5 works and on iOS 5.1 it doesn't, I tried to copy the file from de main bundle resource path to the documents path (above path) and it does not work cause the file its not even found in the main bunlde resource path, but the file is there. What happens on iOS 5.1??

Thanks in advance!!

3

There are 3 answers

0
AudioBubble On

Remove app from simulator and build and Put timer for getDatabasePath for 5 sec. I think it will work.

0
Manish Agrawal On

NSLog the database path from your code and check manually it exist there or not.

0
Travis S On

I was having the same issue. After trying so many different things and took the database out of the program and added it again. This time I made sure I put in a check for the "Add Targets." After doing this it worked fine. If I didn't check it then it wouldn't copy the file over.