Nick Smith
Nick Smith

Reputation: 11

How to create folder in Application folder

Is it possible to create a folder in this path? /var/mobile/Containers/Data/Application

I am using below code but result always NO

[[NSFileManager defaultManager] createDirectoryAtPath:[@"/var/mobile/Containers/Data/Application" stringByAppendingPathComponent:@"testFolderName"] withIntermediateDirectories:NO attributes:nil error:&error]

Upvotes: 0

Views: 105

Answers (1)

Marina Aguilar
Marina Aguilar

Reputation: 1189

You must save your db in the documents directory and retrieve it from there. iOS memory management will always know from where to get your DB even if the path changes.

Check this: save file into application folder using setDownloadDestinationPath

For development purposes you might wanna log your DB path. Just add the following:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *getPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", YOURDBNAME.DB]];

Don't forget to add the extension to the file.

Upvotes: 1

Related Questions