After upgrading to IOS 16.2 getting below exception when trying to access database.
on IOS version 16.1 and below everything works fine.
SqfliteDatabaseException: DatabaseException(open_failed /var/mobile/Containers/Data/Application/494EB596-3835-462C-8164-2B773A19A1C4/Documents/main.db)
File "exception_impl.dart", line 11, in wrapDatabaseException
File "database_mixin.dart", line 737, in SqfliteDatabaseMixin.openDatabase
File "database_mixin.dart", line 839, in SqfliteDatabaseMixin.doOpen
File "database.dart", line 46, in SqfliteDatabaseOpenHelper.openDatabase
File "factory_mixin.dart", line 110, in SqfliteDatabaseFactoryMixin.openDatabase.\<fn\>
...
20 additional frame(s) were not displayed)
Platform: IOS IOS version: 16.2 Device: iPhone 13 pro max. flutter: 3.3.3
Code: databaseFactory.openDatabase(path, options: options);
Plugin: sqflite
On first launch this exception is thrown, but if I close app and relaunch it then it works fine.
I checked if database exists also I added additional catch to get database path from both path_provider and sqflite plugin.
var documentsDirectory = await getApplicationDocumentsDirectory();
String path = join(documentsDirectory.path, "main.db");
try
{
await databaseFactory.openDatabase(path, options: options);
} catch(_) {
try
{
var databasesPath = await getDatabasesPath();
String path = join(databasesPath, 'main.db');
return await databaseFactory.openDatabase(path, options: options);
} catch(e, stackTrace){
reportException(e, stackTrace);
}
}