我是Xamarin的新手,嘗試創建一個APP。當我嘗試在7以下的Android中創建SQLite數據庫時,它完美地工作。但是當我試圖在7和7.1中創建一個數據庫然後得到錯誤。對於這個問題, link in Xamarin discussion forum我整合代碼獲取錯誤以獲取Android 7中的數據庫連接+
public SQLite.Net.SQLiteConnection GetConnection()
{
var sqliteFilename = "ADB.db3";
string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var path = Path.Combine(documentsPath, sqliteFilename);
if (!File.Exists(path))
{
using (var br = new BinaryReader(Android.App.Application.Context.Assets.Open("ATSDB.db3")))
{
using (var bw = new BinaryWriter(new FileStream(path, FileMode.Create)))
{
byte[] buffer = new byte[2048];
int length = 0;
while ((length = br.Read(buffer, 0, buffer.Length)) > 0)
{
bw.Write(buffer, 0, length);
}
}
}
}
// var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroidN();
var conn = new SQLite.Net.SQLiteConnection(plat, path);
// Return the database connection
return conn;
}
**這行我得到錯誤** var conn = new SQLite.Net.SQLiteConnection(plat, path); // Return the database connection
我得到以下錯誤:
{System.DllNotFoundException: libsqlite3_xamarin
at (wrapper managed-to-native) SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroidNInternal:sqlite3_open_v2 (byte[],intptr&,int,intptr)
at SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroidN.Open (System.Byte[] filename, SQLite.Net.Interop.IDbHandle& db, System.Int32 flags, System.IntPtr zvfs) [0x00000] in <360d65bfaa3e44c0b2b5840d827a452d>: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.IDictionary`2[TKey,TValue] tableMappings, System.Collections.Generic.IDictionary`2[TKey,TValue]
extraTypeMappings, SQLite.Net.IContractResolver resolver) [0x00000]
in <8f2bb39aeff94a30a8628064be9c7efe>:0
at ATSDriver.Droid.SqliteService.GetConnection() [0x000b5]
in E:\Projects\DriverApp\Source\ATSDriver\ATSDriver\ATSDriver.Android\SqliteService.cs:52
at ATSDriver.DataAccess..ctor() [0x00009] in E:\Projects\DriverApp\Source\ATSDriver\ATSDriver\ATSDriver\DataAccess.cs:17 }
希望有人們可以幫助我解決這個問題。提前致謝。
感謝您的意見,是怎麼用這個,因爲我已經完成了這個應用程序的所有部分,並在最後我得到這樣的這個非常痛苦的錯誤 –
@A任何例如鏈接,此.Goutam Theres沒有這樣做的指導。它只是刪除舊的'Sqlite.Net' nuget包,而是安裝'Sqlite-Net' nuget包。然後構建並修復任何錯誤。大部分錯誤只會改變名稱空間。這是一個痛苦,但'Sqlite.Net'的所有用戶都在那裏 – user1