hyekyung
hyekyung

Reputation: 671

How to hide specific files in a folder.

I'm making ipad App using SQLite Database.

I want to be able to add .sqlite files from iTunes to add db file freely and to back user_data up.

So, I have to save files on /Documents folder.

Then, I have a question.

I don't want to be able to display some database files in iTunes. - (ex. like user memo db )

What am I supposed to do?

Upvotes: 3

Views: 2033

Answers (1)

Incredible
Incredible

Reputation: 86

If you don't want to display data to user you can use following folders and access the database from the same location which you use for storing

//To access ApplicationSupport folder of your iOS machine

NSString *appSupportDir = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject];

//To access Library folder of your application (i.e. Application/appID/Library)

NSString *libraryDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];

for moving data from one folder to another use following code:

NSFileManager *mngr = [[NSFileManager alloc] init];

NSString *ExpectedFilePath=[[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"Filename.ext"];

//getting Document directory path
NSString *FilePresentAtPath=[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"Filename.ext"];

 // If the database doesn't exist in our Document folder we copy it to Library (this will be executed only one time).
 if (![mngr fileExistsAtPath:ExpectedFilePath])
 {
     [mngr moveItemAtPath:FilePresentAtPath toPath:ExpectedFilePath error:NULL];
 }
[mngr release];

Upvotes: 2

Related Questions