diff --git a/Sources/Amplitude/AMPDatabaseHelper.m b/Sources/Amplitude/AMPDatabaseHelper.m index 5bdef291..f31f64e3 100644 --- a/Sources/Amplitude/AMPDatabaseHelper.m +++ b/Sources/Amplitude/AMPDatabaseHelper.m @@ -81,6 +81,8 @@ @implementation AMPDatabaseHelper { static NSString *const SEQUENCE_NUMBER = @"sequence_number"; +static int const OPEN_DB_FLAGS = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX; + + (AMPDatabaseHelper *)getDatabaseHelper { return [AMPDatabaseHelper getDatabaseHelper:nil]; } @@ -159,7 +161,7 @@ - (BOOL)inDatabase:(void (^)(sqlite3 *db))block { __block BOOL success = YES; dispatch_sync(_queue, ^{ - if (sqlite3_open([self->_databasePath UTF8String], &self->_database) != SQLITE_OK) { + if (sqlite3_open_v2(self->_databasePath.UTF8String, &self->_database, OPEN_DB_FLAGS, NULL) != SQLITE_OK) { AMPLITUDE_LOG(@"Failed to open database"); sqlite3_close(self->_database); success = NO; @@ -195,7 +197,7 @@ - (BOOL)inDatabaseWithStatement:(NSString *)SQLString block:(void (^)(sqlite3_st __block BOOL success = YES; dispatch_sync(_queue, ^{ - if (sqlite3_open([self->_databasePath UTF8String], &self->_database) != SQLITE_OK) { + if (sqlite3_open_v2(self->_databasePath.UTF8String, &self->_database, OPEN_DB_FLAGS, NULL) != SQLITE_OK) { AMPLITUDE_LOG(@"Failed to open database"); sqlite3_close(self->_database); success = NO;