I am trying to build an Android Xamarin Application. I have created an SQLite database named regjistri.sqlite . The database it's not corrupted, I can open it via SQLite browser on my PC. This database I have save it to my android Documents folder. I am trying to access it like below via sqlite-net-pcl library.

string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "regjistri.sqlite");
var db = new SQLiteConnection(dbPath);
var data = db.Query<object>("SELECT COUNT(*) FROM tblLidhja ");

Also I have gice the application the reading and writing permissions. When I debug it via USB cable, it give me the "SQLite.SQLiteException: no such table: tblLidhja" exception. Can someone help me whats may be wrong, or what should I change to read some data?

1

There are 1 best solutions below

0
On

Before getting data , first need to check whether this table is exist in data base .You can refer to this document to check .

By the way ,having a try with this way to get count from database:

var db = new SQLiteConnection("DbPath");
var stocksStartingWithA = db.Query<TableName>("SELECT * FROM DbNmae ");
int count = stocksStartingWithA.Count; //get count from table

Here is similar discussion with java code, but it also can be refer in xamrin project.