G Mehdi Balti
G Mehdi Balti

Reputation: 164

Getting error while making SQLite Connection in Xamarin PCL

I am following this tutorial for SQLite practice in Xamarin:

https://code.tutsplus.com/tutorials/an-introduction-to-xamarinforms-and-sqlite--cms-23020

Now I am stuck here in

public RandomThoughtDatabase () { _connection = DependencyService.Get"ISQLite" ().GetConnection (); }

ISQLite is an interface in PCL

its giving this error

Error CS0119 'DependencyService.Get(DependencyFetchTarget)' is a method, which is not valid in the given context LocalStorage

Upvotes: 0

Views: 398

Answers (1)

hvaughan3
hvaughan3

Reputation: 11105

Use the following instead:

public RandomThoughtDatabase () { _connection = DependencyService.Get<ISQLite>().GetConnection(); }

Upvotes: 2

Related Questions