标签:
1. 下载sqlite.cs:[Table("Items")] public class Stock { [PrimaryKey, AutoIncrement, Column("_id")] public int Id { get; set; } [MaxLength(8)] public string Symbol { get; set; } }
string dbPath = string.Format("{0}//{1}", Environment.GetFolderPath(Environment.SpecialFolder.Personal), "ormdemo.db3"); var db = new SQLiteConnection(dbPath); db.CreateTable<Stock>(); if (!db.Table<Stock>().Any()) { // only insert the data if it doesn‘t already exist var newStock = new Stock { Symbol = "AAPL" }; db.Insert(newStock); newStock = new Stock { Symbol = "GOOG" }; db.Insert(newStock); newStock = new Stock { Symbol = "MSFT" }; db.Insert(newStock); } //Console.WriteLine("Reading data"); var sb = new StringBuffer(); var table = db.Table<Stock>(); foreach (var s in table) { sb.Append(s.Id + " " + s.Symbol); } return sb.ToString();
使用Xamarin + C#开发应用 -- 使用sqlite做本地存储
标签:
原文地址:http://blog.csdn.net/lan_liang/article/details/45542821