原文地址:http://www.codeproject.com/Articles/1097179/SQLite-with-Xamarin-Forms-Step-by-Step-guide

SQLite是移动常见关系型数据库,轻便好用。下面我们就一步步实现xamarin对于sqlite的操作。

创建项目添加NuGet引用

我们采用第三方由oysteinkrog创建的"SQLite-Net-PCL"引用。

由于数据库文件的位置在不同平台存在差异,并且SQLite-Net-PCL不能自动初始化数据库连接对象,所以需要采用历来服务来加载。

Forms interface create

创建Forms的接口文件如下:

  1. using SQLite.Net;

 

  1. namespace SQLiteEx

  1. {


  1. public
  2. interface ISQLite

  1. {

  1. SQLiteConnection GetConnection();

  1. }

  1. }

 

SQLiteService 

创建一个名为'class文件SQLiteService '实施' ISQLite "接口和写本"实施getConnection像下面给出的代码每个特定平台的代码":对于新数据库:当我们创建应用程序本身的一个数据库那么第一次下面的代码将被使用。 

Android:

  1. using System;

  1. using Xamarin.Forms;

  1. using SQLiteEx.Droid;

  1. using System.IO;

 

  1. [assembly: Dependency(typeof(SqliteService))]

  1. namespace SQLiteEx.Droid

  1. {


  1. public
  2. class SqliteService : ISQLite

  1. {


  1. public SqliteService() { }

 


  1. #region ISQLite implementation


  1. public SQLite.Net.SQLiteConnection GetConnection()

  1. {


  1. var sqliteFilename = "SQLiteEx.db3";


  1. string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder


  1. var path = Path.Combine(documentsPath, sqliteFilename);

  1. Console.WriteLine(path);


  1. if (!File.Exists(path)) File.Create(path);


  1. var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();


  1. var conn = new SQLite.Net.SQLiteConnection(plat, path);


  1. // Return the database connection


  1. return conn;

  1. }

 


  1. #endregion

 

 

  1. }

  1. }

 

IOS

  1. using SQLiteEx.iOS;

  1. using System;

  1. using System.IO;

  1. using Xamarin.Forms;

 

  1. [assembly: Dependency(typeof(SqliteService))]

  1. namespace SQLiteEx.iOS

  1. {


  1. public
  2. class SqliteService : ISQLite

  1. {


  1. public SqliteService()

  1. {

  1. }


  1. #region ISQLite implementation


  1. public SQLite.Net.SQLiteConnection GetConnection()

  1. {


  1. var sqliteFilename = "SQLiteEx.db3";


  1. string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder


  1. string libraryPath = Path.Combine(documentsPath, "..", "Library"); // Library folder


  1. var path = Path.Combine(libraryPath, sqliteFilename);

 


  1. // This is where we copy in the prepopulated database

  1. Console.WriteLine(path);


  1. if (!File.Exists(path))

  1. {

  1. File.Create(path);

  1. }

 


  1. var plat = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();


  1. var conn = new SQLite.Net.SQLiteConnection(plat, path);

 


  1. // Return the database connection


  1. return conn;

  1. }


  1. #endregion

  1. }

  1. }

 

对于预创建数据库:在一些应用场合可能有该数据库是一个要求预先填充了一些数据,我们将使用相同的应用程序。在这种情况下首先在遵循特定平台的项目中提到的地点将数据库文件复制,然后使用按照"SQLiteService'类代码Android:复制数据库文件中的"资源\原始" Android平台的项目文件夹中

修改代码如下:

  1. using System;

  1. using Xamarin.Forms;

  1. using SQLiteEx.Droid;

  1. using System.IO;

 

  1. [assembly: Dependency(typeof(SqliteService))]

  1. namespace SQLiteEx.Droid

  1. {

  1.     

  1.     public
  2. class SqliteService : ISQLite {

 

  1.         public SqliteService () {}

 

  1.         #region ISQLite implementation    

  1.         public SQLite.Net.SQLiteConnection GetConnection ()

  1.         {

  1.             var sqliteFilename = "SQLiteEx.db3";

  1.             string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder

  1.             var path = Path.Combine(documentsPath, sqliteFilename);

 

  1.             // This is where we copy in the prepopulated database

  1.             Console.WriteLine (path);

  1.             if (!File.Exists(path))

  1.             {

  1.                 var s = Forms.Context.Resources.OpenRawResource(Resource.Raw.APGameDb); // RESOURCE NAME ###

 

  1.                 // create a write stream

  1.                 FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);

  1.                 // write to the stream

  1.                 ReadWriteStream(s, writeStream);

  1.             }

 

  1.             var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();

  1.             var conn = new SQLite.Net.SQLiteConnection(plat, path);

 

  1.             // Return the database connection

  1.             return conn;

  1.         }

  1.         #endregion

 

 

  1.         void ReadWriteStream(Stream readStream, Stream writeStream)

  1.         {

  1.             int Length = 256;

  1.             Byte[] buffer = new
  2. Byte[Length];

  1.             int bytesRead = readStream.Read(buffer, 0, Length);

  1.             // write the required bytes

  1.             while (bytesRead > 0)

  1.             {

  1.                 writeStream.Write(buffer, 0, bytesRead);

  1.                 bytesRead = readStream.Read(buffer, 0, Length);

  1.             }

  1.             readStream.Close();

  1.             writeStream.Close();

  1.         }

 

 

  1.     }

  1. }

 

var s = Forms.Context.Resources.OpenRawResource(Resource.Raw.APGameDb); // RESOURCE NAME ###

如果这句话存在疑问,证明没有默认数据库文件


我创建了一个文件名sxb.db3 与上文的var sqliteFilename = "SQLiteEx.db3"; 文件名不同
大家自行处理即可,


修改生成操作作为androidResource 既可以在代码中使用了。

创建命名为"PCL项目类DataAccess"。这个类将包含所有应用程序的数据访问代码

  1. using SQLite.Net;

  1. using Xamarin.Forms;

 

  1. namespace SQLiteEx

  1. {


  1. public
  2. class DataAccess

  1. {

  1. SQLiteConnection dbConn;


  1. public DataAccess()

  1. {

  1. dbConn = DependencyService.Get<ISQLite>().GetConnection();


  1. // create the table(s)

  1. dbConn.CreateTable<Employee>();

  1. }


  1. public List<Employee> GetAllEmployees()

  1. {


  1. return dbConn.Query<Employee>("Select * From [Employee]");

  1. }


  1. public
  2. int SaveEmployee(Employee aEmployee)

  1. {


  1. return dbConn.Insert(aEmployee);

  1. }


  1. public
  2. int DeleteEmployee(Employee aEmployee)

  1. {


  1. return dbConn.Delete(aEmployee);

  1. }


  1. public
  2. int EditEmployee(Employee aEmployee)

  1. {


  1. return dbConn.Update(aEmployee);

  1. }

  1. }

  1. }

 

通过DataAccess针对员工表进行操作。其次,代码创建的表没有构造函数,为此,我们将有即使我们使用的是预创建数据库的方法,在数据库中的表会自动检查给,如果不存在,创建它。

创建普通老式CLR对象(POCO)。

例如,' 员工 '为'上面给出的表类数据访问 "类。

员工:

  1. using SQLite.Net.Attributes;

  1. using System;

 

  1. namespace SQLiteEx

  1. {


  1. public
  2. class Employee

  1. {

  1. [PrimaryKey, AutoIncrement]


  1. public
  2. long EmpId

  1. { get; set; }

  1. [NotNull]


  1. public
  2. string EmpName

  1. { get; set; }


  1. public
  2. string Designation

  1. { get; set; }


  1. public
  2. string Department

  1. { get; set; }


  1. public
  2. string Qualification

  1. { get; set; }

  1. }

  1. }

创建"的静态对象属性数据访问的' 应用程序像下面的代码'类。这将使我们能够使用来自应用程序的任何屏幕上操作数据。

  1. using Xamarin.Forms;

  1. using Xamarin.Forms.Xaml;

 

  1. [assembly: XamlCompilation(XamlCompilationOptions.Compile)]

  1. namespace SQLiteEx

  1. {


  1. public
  2. class App : Application

  1. {


  1. static DataAccess dbUtils;


  1. public App()

  1. {


  1. // The root page of your application

  1. MainPage = new NavigationPage(new ManageEmployee());

  1. }


  1. public
  2. static DataAccess DAUtil

  1. {


  1. get

  1. {


  1. if (dbUtils == null)

  1. {

  1. dbUtils = new DataAccess();

  1. }


  1. return dbUtils;

  1. }

  1. }


  1. protected
  2. override
  3. void OnStart()

  1. {


  1. // Handle when your app starts

  1. }

 


  1. protected
  2. override
  3. void OnSleep()

  1. {


  1. // Handle when your app sleeps

  1. }

 


  1. protected
  2. override
  3. void OnResume()

  1. {


  1. // Handle when your app resumes

  1. }

  1. }

  1. }

 

Ios版本

AppDelegate
中增加DataAccess
属性同上

这样就完成了使用SQLite数据库坚持应用程序的数据应用的基本结构
现在,让我们创建示例应用程序看到CRUD操作code.The应用将包含以下屏幕的屏幕:

  1. 管理员工
  2. 添加员工
  3. 显示员工详细信息
  4. 编辑员工

    Xaml

     

    管理员工:此屏幕是应用程序的主屏幕上,它会显示目前员工名单,并给予一个选项,以添加新的员工,查看员工的详细信息和管理部门。此页面的XAML代码将是这样的:

    1. <?xml
    2. version="1.0"
    3. encoding="utf-8"
    4. ?>

    1. <ContentPage
    2. xmlns="http://xamarin.com/schemas/2014/forms"


    1. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"


    1. x:Class="SQLiteEx.ManageEmployee"
    2. Title="Manage Employees"
    3. >


    1. <ContentPage.Padding>


    1. <OnPlatform
    2. x:TypeArguments="Thickness"
    3. iOS="0, 20, 0, 0"
    4. />


    1. </ContentPage.Padding>


    1. <ContentPage.Content>


    1. <ListView
    2. x:Name="lstData"
    3. HasUnevenRows="false"
    4. Header="Header Value"
    5. Footer="Footer"
    6. ItemSelected="OnSelection"
    7. >


    1. <ListView.HeaderTemplate>


    1. <DataTemplate>


    1. <StackLayout
    2. Orientation="Horizontal"
    3. BackgroundColor="Blue"
    4. Padding="5,5,5,5">


    1. <Label
    2. Text="Name"
    3. FontSize="Medium"
    4. FontAttributes="Bold"
    5. TextColor="White"/>


    1. <Label
    2. Text="Designation"
    3. FontSize="Medium"
    4. FontAttributes="Bold"
    5. TextColor="White"/>


    1. <Label
    2. Text="Department"
    3. FontSize="Medium"
    4. FontAttributes="Bold"
    5. TextColor="White"/>


    1. </StackLayout>


    1. </DataTemplate>


    1. </ListView.HeaderTemplate>


    1. <ListView.ItemTemplate>


    1. <DataTemplate>


    1. <ViewCell>


    1. <StackLayout
    2. Orientation="Horizontal"
    3. Padding="5,5,5,5">


    1. <Label
    2. Text="{Binding EmpName}"
    3. FontSize="Medium"
    4. />


    1. <Label
    2. Text="{Binding Designation}"
    3. FontSize="Medium"
    4. />


    1. <Label
    2. Text="{Binding Department}"
    3. FontSize="Medium"
    4. />


    1. </StackLayout>


    1. </ViewCell>


    1. </DataTemplate>


    1. </ListView.ItemTemplate>


    1. <ListView.FooterTemplate>


    1. <DataTemplate>


    1. <StackLayout
    2. Orientation="Horizontal"
    3. Padding="5,5,5,5">


    1. <Button
    2. Text="Add New Employee"
    3. Clicked="OnNewClicked"
    4. />


    1. </StackLayout>


    1. </DataTemplate>


    1. </ListView.FooterTemplate>


    1. </ListView>


    1. </ContentPage.Content>

    1. </ContentPage>

     

    按照上面的XAML,在应用程序执行" OnSelection上''的方法ItemSelected名单"事件,以显示详细的员工信息,"OnNewClicked '上'的方法点击了 '的'事件添加新员工 "按钮。本页面背后的代码将包含以下代码。

    1. using System;

    1. using Xamarin.Forms;

     

    1. namespace SQLiteEx

    1. {


    1. public
    2. partial
    3. class ManageEmployee : ContentPage

    1. {


    1. public ManageEmployee()

    1. {

    1. InitializeComponent();


    1. var vList = App.DAUtil.GetAllEmployees();

    1. lstData.ItemsSource = vList;

    1. }

     


    1. void OnSelection(object sender, SelectedItemChangedEventArgs e)

    1. {


    1. if (e.SelectedItem == null)

    1. {


    1. return;


    1. //ItemSelected is called on deselection,


    1. //which results in SelectedItem being set to null

    1. }


    1. var vSelUser = (Employee)e.SelectedItem;

    1. Navigation.PushAsync(new ShowEmplyee(vSelUser));

    1. }


    1. public
    2. void OnNewClicked(object sender, EventArgs args)

    1. {

    1. Navigation.PushAsync(new AddEmployee());

    1. }

    1. }

    1. }

     

    添加员工:顾名思义这个页面将用于增加新的员工,将根据点击的被称为"添加新员工"员工管理"页上的按钮。此页面的XAML代码将是这样的:

    隐藏   复制代码

    <?xml
    version="1.0"
    encoding="utf-8"
    ?>

    <ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="SQLiteEx.AddEmployee"
    Title="Add New Employee">

    <ContentPage.Content>

                 <TableView
    Intent="Settings"
    BackgroundColor="White">

                     <TableRoot>

                         <TableSection
    Title="Add New Employee">

                             <EntryCell
    x:Name="txtEmpName"
    Label="Employee Name"
    Keyboard="Text"
    />

                             <EntryCell
    x:Name="txtDesign"
    Label="Designation"
    Keyboard="Text"
    />

                             <EntryCell
    x:Name="txtDepartment"
    Label="Department"
    Keyboard="Text"
    />

                             <EntryCell
    x:Name="txtQualification"
    Label="Qualification"
    Keyboard="Text"
    />

                             <ViewCell>

                                 <ContentPage
    Padding="0,0">

    <ContentPage.Padding>

    <OnPlatform
    x:TypeArguments="Thickness"
    iOS="10,0"
    WinPhone="0,15,0,0"
    />

    </ContentPage.Padding>

    <ContentPage.Content>

    <Button
    BackgroundColor="#fd6d6d"
    Text="Save"
    TextColor="White"
    Clicked="OnSaveClicked"
    />

    </ContentPage.Content>

    </ContentPage>

                             </ViewCell>

                         </TableSection>

                     </TableRoot>

                 </TableView>

    </ContentPage.Content>

    </ContentPage>

    本页面背后的代码将包含以下代码:

    隐藏   复制代码

    using System;

    using Xamarin.Forms;

     

    namespace SQLiteEx

    {

    public
    partial
    class AddEmployee : ContentPage

    {

    public AddEmployee()

    {

    InitializeComponent();

    }

     

    public
    void OnSaveClicked(object sender, EventArgs args)

    {

    var vEmployee = new Employee()

    {

    EmpName = txtEmpName.Text,

    Department = txtDepartment.Text,

    Designation = txtDesign.Text,

    Qualification = txtQualification.Text

    };

    App.DAUtil.SaveEmployee(vEmployee);

    Navigation.PushAsync(new ManageEmployee());

    }

    }

    }

     

    显示员工详细信息:顾名思义,这个页面将用于显示雇员的完整细节,也将必须调用"编辑员工页面的选项,"删除员工"从数据库中删除员工的详细信息。此页面的XAML代码是这样的:

    1. <?xml
    2. version="1.0"
    3. encoding="utf-8"
    4. ?>

    1. <ContentPage
    2. xmlns="http://xamarin.com/schemas/2014/forms"
    3. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    4. x:Class="SQLiteEx.ShowEmplyee"
    5. Title="View Employee">


    1. <ContentPage.Content>


    1. <Grid>


    1. <Grid.RowDefinitions>


    1. <RowDefinition
    2. Height="*"/>


    1. <RowDefinition
    2. Height="*"/>


    1. <RowDefinition
    2. Height="*"/>


    1. <RowDefinition
    2. Height="*"/>


    1. <RowDefinition
    2. Height="*"/>


    1. <RowDefinition
    2. Height="*"/>


    1. <RowDefinition
    2. Height="*"/>


    1. </Grid.RowDefinitions>

     


    1. <Grid.ColumnDefinitions>


    1. <ColumnDefinition
    2. Width="10"/>


    1. <ColumnDefinition
    2. Width="*"/>


    1. <ColumnDefinition
    2. Width="*"/>


    1. <ColumnDefinition
    2. Width="10"/>


    1. </Grid.ColumnDefinitions>

     


    1. <Label
    2. Grid.Row
    3. ="0"
    4. Grid.Column="0"
    5. Grid.ColumnSpan="2"
    6. Text="Employee Details"
    7. />


    1. <Label
    2. Grid.Row
    3. ="1"
    4. Grid.Column="1"
    5. Text="Name"
    6. />


    1. <Label
    2. Grid.Row="1"
    3. Grid.Column="2"
    4. Text
    5. ="{Binding EmpName}"
    6. />


    1. <Label
    2. Grid.Row
    3. ="2"
    4. Grid.Column="1"
    5. Text="Designation"
    6. />


    1. <Label
    2. Grid.Row="2"
    3. Grid.Column="2"
    4. Text
    5. ="{Binding Designation}"/>


    1. <Label
    2. Grid.Row
    3. ="3"
    4. Grid.Column="1"
    5. Text="Department"
    6. />


    1. <Label
    2. Grid.Row="3"
    3. Grid.Column="2"
    4. Text
    5. ="{Binding Department}"/>


    1. <Label
    2. Grid.Row
    3. ="4"
    4. Grid.Column="1"
    5. Text="Qualification"
    6. />


    1. <Label
    2. Grid.Row="4"
    3. Grid.Column="2"
    4. Text
    5. ="{Binding Qualification}"
    6. />


    1. <Button
    2. Grid.Row
    3. ="5"
    4. Grid.Column="1"
    5. Text="Edit Details"
    6. Clicked="OnEditClicked"
    7. />


    1. <Button
    2. Grid.Row="5"
    3. Grid.Column="2"
    4. Text="Delete"
    5. Clicked="OnDeleteClicked"
    6. />


    1. </Grid>


    1. </ContentPage.Content>

    1. </ContentPage>

    而这个页面背后的代码将包含以下代码:

    1. using System;

    1. using Xamarin.Forms;

     

    1. namespace SQLiteEx

    1. {


    1. public
    2. partial
    3. class ShowEmplyee : ContentPage

    1. {

    1. Employee mSelEmployee;


    1. public ShowEmplyee(Employee aSelectedEmp)

    1. {

    1. InitializeComponent();

    1. mSelEmployee = aSelectedEmp;

    1. BindingContext = mSelEmployee;

    1. }

     


    1. public
    2. void OnEditClicked(object sender, EventArgs args)

    1. {

    1. Navigation.PushAsync(new EditEmployee(mSelEmployee));

    1. }


    1. public
    2. async
    3. void OnDeleteClicked(object sender, EventArgs args)

    1. {


    1. bool accepted = await DisplayAlert("Confirm", "Are you Sure ?", "Yes", "No");


    1. if (accepted)

    1. {

    1. App.DAUtil.DeleteEmployee(mSelEmployee);

    1. }


    1. await Navigation.PushAsync(new ManageEmployee());

    1. }

    1. }

    1. }

     

    编辑员工:顾名思义,这个页面将用于编辑员工的详细信息。此页面的XAML代码是这样的:

    1. <?xml
    2. version="1.0"
    3. encoding="utf-8"
    4. ?>

    1. <ContentPage
    2. xmlns="http://xamarin.com/schemas/2014/forms"
    3. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    4. x:Class="SQLiteEx.EditEmployee"
    5. Title="Edit Employee">


    1. <ContentPage.Content>


    1. <TableView
    2. Intent="Settings"
    3. BackgroundColor="White">


    1. <TableRoot>


    1. <TableSection
    2. Title="Edit Employee">


    1. <EntryCell
    2. x:Name="txtEmpName"
    3. Label="Employee Name"
    4. Text
    5. ="{Binding EmpName}"
    6. Keyboard="Text"
    7. />


    1. <EntryCell
    2. x:Name="txtDesign"
    3. Label="Designation"
    4. Text
    5. ="{Binding Designation}"
    6. Keyboard="Text"
    7. />


    1. <EntryCell
    2. x:Name="txtDepartment"
    3. Label="Department"
    4. Text
    5. ="{Binding Department}"
    6. Keyboard="Text"
    7. />


    1. <EntryCell
    2. x:Name="txtQualification"
    3. Label="Qualification"
    4. Text
    5. ="{Binding Qualification}"
    6. Keyboard="Text"
    7. />


    1. <ViewCell>


    1. <ContentPage
    2. Padding="0,0">


    1. <ContentPage.Padding>


    1. <OnPlatform
    2. x:TypeArguments="Thickness"
    3. iOS="10,0"
    4. WinPhone="0,15,0,0"
    5. />


    1. </ContentPage.Padding>


    1. <ContentPage.Content>


    1. <Button
    2. BackgroundColor="#fd6d6d"
    3. Text="Save"
    4. TextColor="White"
    5. Clicked="OnSaveClicked"
    6. />


    1. </ContentPage.Content>


    1. </ContentPage>


    1. </ViewCell>


    1. </TableSection>


    1. </TableRoot>


    1. </TableView>


    1. </ContentPage.Content>

    1. </ContentPage>

    而这个页面背后的代码将包含以下代码:

    而这个页面背后的代码将包含以下代码:

    隐藏   复制代码

    using System;

    using Xamarin.Forms;

     

    namespace SQLiteEx

    {

    public
    partial
    class EditEmployee : ContentPage

    {

    Employee mSelEmployee;

    public EditEmployee(Employee aSelectedEmp)

    {

    InitializeComponent();

    mSelEmployee = aSelectedEmp;

    BindingContext = mSelEmployee;

    }

     

    public
    void OnSaveClicked(object sender, EventArgs args)

    {

    mSelEmployee.EmpName = txtEmpName.Text;

    mSelEmployee.Department = txtDepartment.Text;

    mSelEmployee.Designation = txtDesign.Text;

    mSelEmployee.Qualification = txtQualification.Text;

    App.DAUtil.EditEmployee(mSelEmployee);

    Navigation.PushAsync(new ManageEmployee());

    }

    }

SQLite for xamarin的更多相关文章

  1. Xamarin SQLite教程Xamarin.iOS项目添加引用

    Xamarin SQLite教程Xamarin.iOS项目添加引用 使用直接方式访问SQLite数据库,需要将System.Data和Mono.Data.SQlite库导入到创建的项目中.下面将分别讲 ...

  2. Xamarin android使用Sqlite做本地存储数据库

    android使用Sqlite做本地存储非常常见(打个比方就像是浏览器要做本地存储使用LocalStorage,貌似不是很恰当,大概就是这个意思). SQLite 是一个软件库,实现了自给自足的.无服 ...

  3. How to Make Portable Class Libraries Work for You

    A Portable Class Library is a .NET library that can be used (in binary form, without recompiling) on ...

  4. xamarin SQLite路径

    xamarin使用SQLite时对应的访问路径各个平台不一样,需要单独引用.在使用前添加SQLite引用包,在解决方案上右击选择解决方案的Nuget管理选项,在浏览中输入sqlite-net-pcl, ...

  5. [Xamarin] 關於SQLite 的操作 (转帖)

    我們聊一下常用的東西,SQLite,這東西很常用到,當再寫手機APP的時候,有時候會在Client 做 cache或是做一些資料的管理都很必須會用到,我們來看看今天的範例 建立SQL Lite 資料庫 ...

  6. Xamarin android 的WebClient Json下载并存储本地及sqlite数据库

    这一点雕虫小技可能对熟悉的人来说已经不值一提.但是我想,既然这些都是常用的功能,集成在一起做个笔记也有点意义吧. 首先,json 是传递数据的事实标准了.所以先说一下将它从服务器端下载下来..net ...

  7. Xamarin.Forms 使用本地数据库之 SQLite

    前言 Xamarin.Forms支持使用SQLite数据库引擎.本文介绍了Xamarin.Forms应用程序如何读取和写入数据到使用SQLite.Net的本地SQLite数据库. 在Xamarin.F ...

  8. Xamarin SQLite教程数据库访问与生成

    Xamarin SQLite教程数据库访问与生成 在本教程中,我们将讲解如何开发SQLite相关的App.在编写程序前,首先需要做一些准备工作,如了解Xamarin数据库访问方式,添加引用,构建使用库 ...

  9. Xamarin.Android之SQLite.NET ORM

    一.前言 通过<Xamarin.Android之SQLiteOpenHelper>和<Xamarin.Android之ContentProvider>的学习,我们已经掌握了如何 ...

随机推荐

  1. android——wifi系统架构

    1. 系统架构 Android WiFi系统引入了wpa_supplicant,它的整个WiFi系统以wpa_supplicant为核心来定义上层用户接口和下层驱动接口.整个WiFi系统架构如下图所示 ...

  2. Lucene中string docvalues使用utf-16的优化

    原来的string docvalues使用utf-8编码,载入时转码花费大量时间,我们把转码实现从new String(bytes, "UTF-8")改用lucene的bytesR ...

  3. mysql源码分析

    http://blog.csdn.net/u012935160/article/category/2697485

  4. linux下显卡信息的查看

    lspci  | grep -i vga 这样就可以显示机器上的显卡信息,比如 [root@localhost conf]# lspci | grep -i vga01:00.0 VGA compat ...

  5. CentOS7搭建SAMBA服务器实现与WIN10匿名共享文件

    1.安装SAMBA yum -y install samba samba-client samba-common 2.修改文件打开数 vi /etc/security/limits.conf 最后添加 ...

  6. 浪漫桃心的Android表白程序

    本文转载于  huachao1001的专栏 几年前,看到过有个牛人用HTML5绘制了浪漫的爱心表白动画.地址在这:浪漫程序员 HTML5爱心表白动画.发现原来程序员也是可以很浪……漫…..的.那么在A ...

  7. codevs 最佳落点(模拟)

    /* 这题并没有A掉 自己电脑上运行ok提交就不对 预处理攻击范围 然后模拟 求大神看看有没有错误 Orz */ #include<iostream> #include<cstdio ...

  8. JS操作DOM元素属性和方法

    Dom元素基本操作方法API,先记录下,方便以后使用. W3C DOM和JavaScript很容易混淆不清.DOM是面向HTML和XML文档的API,为文档提供了结构化表示,并定义了如何通过脚本来访 ...

  9. #BeginLibraryItem 的疑问...

    <!-- #BeginLibraryItem "/library/ur_here.lbi" --><div style="padding:3px 15p ...

  10. linux list all users.

    cat /etc/passwd sample of list users in linux. ref: Linux Command: List All Users In The System