Database not persisted between builds with xamarin ios Database not persisted between builds with xamarin ios sqlite sqlite

Database not persisted between builds with xamarin ios


This is a code snippet I've used to save my databases in the iOS simulator and the data seems to persist between app compiles just fine:

string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); string libraryPath = Path.Combine (documentsPath, "../Library/");var path = Path.Combine (libraryPath, "MyDatabase.db3");

You may also want to check out the SQLite class for Xamarin off of Github:https://github.com/praeclarum/sqlite-net/tree/master/src

Here's a tutorial on how to use said class:http://docs.xamarin.com/recipes/ios/data/sqlite/create_a_database_with_sqlitenet


Turns out that I was creating the connection object using the CNN_STRING which just had the db-name instead of the full path to the db. Apperantly the connection object creates the database if the file doesn't exist so the File.Exists(...) might not be needed. I'm not really sure if it should be a temporary db if the complete path is not supplied but it seems to be the case. Changing the creation of the connection object to "datasource=" solved the problem.