Greg Jones
Greg Jones

Reputation: 397

How to use SQLite with Xamarin in a Common Project

I'm building an iOS and Android app. I want to create a Common Library for as much as possible. Is there an approach I can use for SQLite.Net in this manner or am I stuck with repeated code in both app projects? The Component seems to be unique per platform.

Upvotes: 1

Views: 94

Answers (2)

Jared Reeves
Jared Reeves

Reputation: 1390

If you are using the SQLite.Net PCL there are several things you need to do to be able to use the lite DB in both the iOS and Android app. You will still need to implant some platform specific code, but this is only to hook up the database to each platform.

You can then code a database layer that is use by both platforms. This Example should help you out Xamarin TODO PCL.

If on the other hand you are using the shared library concept you can use this example Xamarin TODO Shared.

Note: if you have any more specific questions, let me know as I have recently implemented this for an iOS app

Upvotes: 1

Jason
Jason

Reputation: 89204

The component is platform specific, but there is a PCL Package that you can install from NuGet that should work cross-platform.

Upvotes: 1

Related Questions