2015-12-17 2 views
-2
- (void) copyDatabaseIfNeeded 
{ 
    BOOL success; 
    NSFileManager *fileManager = [NSFileManager defaultManager]; 
    NSError *error; 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:ABC.Sqlite]; 
    success = [fileManager fileExistsAtPath:writableDBPath]; 
    if (success) return; 
    // The writable database does not exist, so copy the default to the appropriate location. 
    NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:ABC.Sqlite]; 
    success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error]; 
    if (success) 
    { 
     NSURL *url=[NSURL URLWithString:WSURL2]; 

    } else 
    { 
     NSLog(@"Failed to create writable database file with message '%@'.", [error localizedDescription]); 
    } 
} 

Мне нужно добавить код для просмотра Sqlite File ??Невозможно увидеть SQLite-файл в iTunes

Я попробовал, добавив их в Plist: UIFileSharingEnabled, CFBundleDisplayName

Как я просматривать мой файл SQLite в Itunes?

Приглашение ссылки: How to enable file sharing for my app?, UIFileSharingEnabled has no effect

Если я включен обмен вариант в мое приложение резервного копирования данных приложений в ПК ITunes файл, будет AppStore отторгает приложение?

+0

Сохраните файл в папке «Документы» в приложении? Покажите соответствующий код. – rmaddy

+0

Я отредактировал код, пожалуйста, проверьте один раз, мне нужно добавить любой код для просмотра Sqlite File ?? @rmaddy – Sanju

ответ

2

Вы не создаете файл в папке Documents, но каталог библиотеки:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); 
//             ^^^^^^^^^^^^^^^^^^ 

Вы хотите NSDocumentDirectory.

+0

работал, спасибо. @trojanfoe – Sanju

+0

Не забудьте отключить общий доступ к файлам iTunes перед загрузкой в ​​App Store. В противном случае ваше приложение будет отклонено. –

Смежные вопросы