Hello,
Welcome to our Microsoft Q&A platform!
The Android version of SQLite has a limitation that requires a few more steps. If the call to SqliteConnection.SetConfig
produces a SQLite exception such as library used incorrectly, then you must use the following workaround:
1.Link to the native libsqlite.so library so that the sqlite3_shutdown and sqlite3_initialize APIs are made available to the app:
[DllImport("libsqlite.so")]
internal static extern int sqlite3_shutdown();
[DllImport("libsqlite.so")]
internal static extern int sqlite3_initialize();
2.At the very beginning of the OnCreate method, add this code to shutdown SQLite, configure it for Serialized mode, and reinitialize SQLite:
using using Mono.Data.Sqlite;
...
sqlite3_shutdown();
SqliteConnection.SetConfig(SQLiteConfig.Serialized);
sqlite3_initialize();
Best Regards,
Jessie Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.