Reputation: 14408
I am not sure if it is the expected behavior.
I have xcode 4.3.2, and running an application, where in i get the default Document directory by the following code.
NSArray *dirPaths;
NSString *docsDirectory;
NSString *databasePath;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDirectory = [dirPaths objectAtIndex:0];
databasePath = [[NSString alloc] initWithString: [docsDirectory stringByAppendingPathComponent: DBNAME]];
const char *dbpath = [databasePath UTF8String];
NSFileManager *filemgr = [NSFileManager defaultManager];
if ([filemgr fileExistsAtPath:databasePath] == NO) {
NSLog (@" GETDBPATHNAME: database file does not exist");
}
else {
NSLog (@" GETDBPATHNAME: Database File EXISTS");
}
Use Cases: 1) I run the application each time in xcode the path is same. 2) Reboot the device, and re run the application in xcode, also the path is same. 3) BUT WHEN I DELETE THE APPLICATION, AND RE-RUN IN THE PATH DIFFERS. How it is possible?
What get the path something like:
/var/mobile/Applications/xxxxxxx-xxx-xxxx-xxx-xxxxxxxxxxx/Documents/
The value xxxxxxx-xxx-xxxx-xxx-xxxxxxxxxxx claimed to be a Phone UUID. How it is different each time?
Your help is much appreciated.
Upvotes: 0
Views: 1030
Reputation: 229
Whenever you delete and reinstall the application this path changes.
xxxxxxx-xxx-xxxx-xxx-xxxxxxxxxxx is not the phone UUID otherwise this path would have been the same for every application. Further More this path is also changed when you update your application on the app store.
So the solution to avoid this problem is to save the path after /Documents Directory and use
stringByAppendingPathComponent:
after the path to the Documents Directory to get the full path. In this way you would not have any problem regarding the path of the resource.
Upvotes: 0
Reputation: 107121
Each application has a UNIQUE document directory. When you delete an APP the document directory is also get deleted. Then when you install the same application. The iOS generates another directory for the APP. It never use the previous directory name for this purpose.
Upvotes: 2