Level : WORDPRESS BOOK LINKEDIN PATENT Send Mail 동냥하기 hajunho.com

081

살며 생각하며, / / 2020. 2. 8. 10:47
반응형

NSString *databaseName = @"my.db";

    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *documentsDir = [documentPaths objectAtIndex:0];

    NSString *databasePath = [documentsDir stringByAppendingPathComponent:databaseName];

    // Check if the SQL database has already been saved to the users phone, if not then copy it over

    BOOL success;

    // Create a FileManager object, we will use this to check the status

    // of the database and to copy it over if required

    NSFileManager *fileManager = [NSFileManager defaultManager];

    // Check if the database has already been created in the users filesystem

    success = [fileManager fileExistsAtPath:databasePath];

    // If the database already exists then return without doing anything

    if(success) return;

    // If not then proceed to copy the database from the application to the users filesystem

    // Get the path to the database in the application package

    NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];

    NSLog(@"databasePathFromApp %@", databasePathFromApp);

    // Copy the database from the package to the users filesystem

    [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];

반응형

'살며 생각하며,' 카테고리의 다른 글

083 IT 교육자 간 갈등의 자그만 조각 외  (0) 2020.02.08
082 클라우드 업체 선정 외  (0) 2020.02.08
080  (0) 2020.02.07
079  (0) 2020.01.21
078  (0) 2020.01.20
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기