I am having continuous crashes in ios, when trying to access sqlite database. My application has background sync process where it tries to fetch the data and store it in sql database in device. Some how in IOS device randomly it crashes.
one of the log is:
SQLite.SQLiteException: Corrupt
SQLiteCommand.ExecuteNonQuery () /Users/vagrant/git/src/SQLite.cs:2334 SQLiteConnection.Execute (System.String query, System.Object[] args) /Users/vagrant/git/src/SQLite.cs:673 DataAccessBase.TruncateData (System.Boolean isSyncRestarted) /Users/yagnaios/Documents/Documents - Venu’s MacBook Pro/Dev_Latest/TCRMobile/TCRMobile/DataAccess/DataAccessBase.cs:93 Home+d__16.MoveNext () /Users/yagnaios/Documents/Documents - Venu’s MacBook Pro/Dev_Latest/TCRMobile/TCRMobile/Pages/Home.cs:307 ExceptionDispatchInfo.Throw () /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
The app works fine in android but it is serious problem in IOS because once the database is corrupt, we are unable to use the app.
You need to configure the database to serialize its access to the file. Make make sure you're staying away from threads/tasks in your code, or make sure that only one thread at a time is trying to write to the database.
For more information you can access here