0

I create my first mobile app in Xamarin Forms. As I'm a C#.NET developer, I was thinking straight forward methods to manage with databases.

I have a pre-loaded database "MyStoryTitles.db3", and I just want to show the contents.

My thinking was to:

  • store the db3 file in a folder named Data
  • connect to the file
  • use list view to show the content

But when I researched, I came to know that we cannot do the SQLite in straight forward methods. What I understood from the online articles that I have to:

  • store the db3 file as Asset ( for Android)
  • copy the file prior opening it ( as shown here)
  • connect to the local copied db
  • use list view to show the content

Is this the standard procedure ? Or can I store the db3 file as EmbeddedResource and do the database operation as normal ?

Rauf
  • 12,326
  • 20
  • 77
  • 126
  • Where do you put the EmbeddedResource db3 file? In Xamarin.Forms or just in Xamarin .Android? – Wendy Zang - MSFT Feb 02 '21 at 09:36
  • yes, that's the standard process. SQLite cannot open a DB that is stored as an embedded resource or asset, that is why you need to copy it to a folder first – Jason Feb 02 '21 at 09:56
  • @Jason So is there any way to do direct connection ? – Rauf Feb 02 '21 at 12:37
  • @Wendy Zang - MSFT Right now, I put in a new folder named Data, with build Action EmbeddedResource – Rauf Feb 02 '21 at 12:43
  • if you want to write to the database, you must do it this way. If your db is read-only you can try including it as a file in your platform project and opening the SQLiteConnection directly from there – Jason Feb 02 '21 at 13:16

0 Answers0