3

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?

Andy
  • 521
  • 3
  • 6
  • 22
hyekyung
  • 671
  • 2
  • 14
  • 27
  • Take a look at this question, http://stackoverflow.com/questions/2942855/iphone-documents-directory-and-uifilesharingenabled-hiding-certain-documents – Chris Wagner Dec 08 '11 at 06:11

1 Answers1

2

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];
Incredible
  • 86
  • 7