I'm trying to create a database using SQLite
try {
_conn = new SQLiteConnection(_dbPath);
_conn.CreateTable<Product>();
}
catch (Exception ex) {
throw ex;
}
it is supposed to create database at _dbPath
if it doesn't exist.
_dbPath
value is /storage/emulated/0/Phone Catalog/PhoneCatalogDatabase.db3
which is the default location when opening File Manager in Emulator( http://i.imgur.com/fYOT46x.png )
I get exception saying: Could not open database file: /storage/emulated/0/Phone Catalog/PhoneCatalogDatabase.db3 (CannotOpen)
Any ideas why I get the message? Maybe there is a permission issue or something.
PS here is Products
class if you need to see it
[Table("Products")]
public class Product {
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
public string Manufacturer { get; set; }
public int Price { get; set; }
}
OK, I had very simple mistake. Phone Catalog
doesn't exist and that was the problem. I thought sqllite
would create it but it only creates database file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.