2011-12-08 17 views
3

私はSQLiteデータベースを使ってipadアプリケーションを作っています。フォルダ内の特定のファイルを非表示にする方法。

私はiTunesから.sqliteファイルを追加して、自由にdbファイルを追加し、user_dataをバックアップできるようにしたいと考えています。

したがって、/ Documentsフォルダにファイルを保存する必要があります。

次に、質問があります。

iTunesにいくつかのデータベースファイルを表示したくない場合があります。 - (例:user memo db)

私は何をすべきですか?

+0

はこの質問、http://stackoverflow.com/questions/2942855/iphone-documents-directory-and-uifilesharingenabled-hiding-certain-documentsを見てみましょう:次のコードを使用します –

答えて

2

あなたは以下のフォルダを使用して、iOS搭載機

のApplicationSupportフォルダにアクセスするには

//を格納するために使用するのと同じ場所からデータベースにアクセスできるユーザーにデータを表示したくない場合

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

//アプリケーションのライブラリフォルダにアクセスするために(すなわちアプリケーション/ appIDが/ライブラリ)を別のフォルダからデータを移動するための

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

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]; 
関連する問題