2016-11-28 10 views
1

バックアップのために現在の.sqliteファイルの場所を見つける必要があります。どうすればいいですか?これは、 "ファイルが見つかりません" を返し、私が持っているコードです:私はGoogleのを見て、SOきデバイス上の現在の.sqliteファイルを見つける方法(iPad)

-(NSString *)createCoreDataStorePath { 

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); 
NSString *applicationSupportDirectory = [paths firstObject]; 

NSString *coreDataStorePath = [applicationSupportDirectory stringByAppendingPathComponent:@"/books"]; 
NSLog(@"\n\ncoreDataStorePath: %@", coreDataStorePath); 

return coreDataStorePath; 

}

:ここ

// find current directory for saori.sqlite 
NSString *coreDataStorePath = [self createCoreDataStorePath]; 
// sqlite store setup 
NSString *storePath = [coreDataStorePath stringByAppendingPathComponent:@"BookstoreInventoryManager.sqlite"]; // Application Support/SalonBook/saori.sqlite/saori.sqlite 
NSLog(@"\n\nBACKUP - storePath: %@",storePath); 

NSFileManager *fileManager = [NSFileManager defaultManager]; 
if ([fileManager fileExistsAtPath: storePath]) 
    [MagicalRecord cleanUp]; // set stack, etc to 'nil' 
else { 
    NSLog(@"\n\n-->BookstoreInventoryManager files not found"); // log message "unable to find sqlite files 
    return; 
} 

createCoreDataStorePathのコードです私の答えは見つからなかった。

+0

'coreDataStorePath'とは何ですか?あなたはどうやってそれを保持していますか? 'NSApplicationSupportDirectory'では? – Larme

答えて

1

私はそれを考え出した...このコードを使用:

-(NSString *)applicationDocumentsDirectory { 

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; 
return basePath; 

}

それは私の店の実際のURLを与える...あなたのおかげLarmeあなたの応答のために。 SD

関連する問題