How to access a prepopulated SQLite database built into a Xamarin.forms app?

I need my app to contain a prepopulated database that is created outside the app, that the app can use and update.

It seems like a basic necessity, I expected it would be easy like this:

  • Add the MyData.db file to the project
  • Choose the correct build action property for it, like a resource
  • Get the path for app resources, DBPath = App.PathToResources + "MyData.db"
  • connection = new SQLiteConnection(DBPath)
  • Read/write data with SQL queries

I haven’t found anything that works. It seems impossible to include a db file in my project AND access it in the code.

The question is, how do I build the data into my app? What’s the right paradigm here?

Thank you.

Source: Xamarin.ios Questions