I am facing SQLite issue in xamarin forms project. However SQLiteConnection
I am trying to instantiating in Android platform there getting exception.
Libraries using in android & iOS project
- SQLite.Net-PCL 3.1.1
- SQLite.Net.Core-PCL 3.1.1
menifest file target versions
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />
AndroidSQLite.cs file
using SQLite;
using SQLite.Net;
using System.IO;
namespace XamarinTestList.Droid.Implementations
{
public class AndroidSQLite : ISQLite
{
public SQLiteConnection GetConnection()
{
string documentPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var path = Path.Combine(documentPath, DatabaseHelper.DbFileName); //DbFileName="Contacts.db"
var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
string dpPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3");
var conn= new SQLiteConnection(plat, dpPath);
return conn;
}
}
}
Getting exception at
var conn= new SQLiteConnection(plat, dpPath);
I have installed above libraries on solution level but in shared project, there is no option available to install Nuget packages. Shared project screen shot
Following this article to learn SQLite with xamarin xamarin forms-mvvm-sqlite-sample.
Full exception below
{System.DllNotFoundException: /system/lib/libsqlite.so at (wrapper managed-to-native) SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroidInternal.sqlite3_open_v2(byte[],intptr&,int,intptr) at SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroid.Open (System.Byte[] filename, SQLite.Net.Interop.IDbHandle& db, System.Int32 flags, System.IntPtr zvfs) [0x00000] in <8dbf6ff85082469fb9d4dfaa9eae6b69>:0 at SQLite.Net.SQLiteConnection..ctor (SQLite.Net.Interop.ISQLitePlatform sqlitePlatform, System.String databasePath, SQLite.Net.Interop.SQLiteOpenFlags openFlags, System.Boolean storeDateTimeAsTicks, SQLite.Net.IBlobSerializer serializer, System.Collections.Generic.IDictionary
2[TKey,TValue] tableMappings, System.Collections.Generic.IDictionary
2[TKey,TValue] extraTypeMappings, SQLite.Net.IContractResolver resolver) [0x000a2] in <8f2bb39aeff94a30a8628064be9c7efe>:0 at SQLite.Net.SQLiteConnection..ctor (SQLite.Net.Interop.ISQLitePlatform sqlitePlatform, System.String databasePath, System.Boolean storeDateTimeAsTicks, SQLite.Net.IBlobSerializer serializer, System.Collections.Generic.IDictionary2[TKey,TValue] tableMappings, System.Collections.Generic.IDictionary
2[TKey,TValue] extraTypeMappings, SQLite.Net.IContractResolver resolver) [0x00000] in <8f2bb39aeff94a30a8628064be9c7efe>:0
SQLite.Net.Platform
Platform is not available. – R15