Reputation: 8292
I start an Android native application with Xamarin, I have created a PCL library to share models and common stuff with the iOS version of the app.
I want a database in this application so I'm want to use the nugget SQLite PCL library to do it. But to use it I need Xamarin.Forms.Dependency
to have iOS and Android implementations.
Can I use Xamarin.Forms.Dependency
on a non forms project ? Or is there another way to make a cross platform database ?
Upvotes: 2
Views: 498
Reputation: 1196
An Xamarin "Forms" app is basically a Native app on top of a PCL with references to the Xamarin Forms controls.
So Yes you should be able to reference Xamarin Forms in your PCL without issue. Create your Connection in your platform specific. and pass it in.
If you have issue just create a new xamarin Forms app and take alook at the references and packages you'd want to mimic that in your app.
Upvotes: 0
Reputation: 11787
You have to use dependency injection which I believe is what XF is doing. You need not include it in the common project.
Add SQLite PCL to ios project and android project and the common project where you are creating the repositories. The you can invoke the common project from native projects by passing in the SQLite.Platform and the database path.
Also I believe SQLite.Net.Async PCL is a bit faster.
Upvotes: 1