I have been using the sqlite-net-pcl plugin for some, but the play store now requires an app to target Android version 7 at a minimum.
When I target this (Target Android Versions - 7.1), the application cannot open/create the database it only works for the lower version of Android, such as 5. I'm aware that there were security changes that may have caused this but I've no idea how to address it.
I get a datapath for android like so Path.Combine(global::Android.OS.Environment.ExternalStorageDirectory.Path, filename);
Then when starting my app tries to open the database connection like so
string dbPath = DependencyService.Get<IFileHelper>().GetLocalFilePath("myDbName.db3");
var conn = new SQLiteAsyncConnection(dbPath);
I want to use the SQLiteAsyncConnection
as that handles the table locks.
The exception is:
Unhandled Exception:
SQLite.SQLiteException: Could not open database file: /storage/emulated/0/myDbName.db3 (CannotOpen)
I've also ensured I have read and write ticked for external storage permission. The plugin I am using is https://github.com/praeclarum/sqlite-net which is what xamarin forms recommend in their documentation.