本节顺序与内容参考了,张引的《Xamarin全栈开发技术与实践》第六章内容。
本节讲两种本地存储方法,偏好存储(少量,临时)与本地数据库。
首先上代码
mainPage.xamlde:
<?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="DataWR.MainPage">
<StackLayout>
<Grid Margin="4">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Entry x:Name="PreferenceEntry"
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"/>
<Button x:Name="PreferenceSaveButton"
TextTransform="None"
Grid.Row="1"
Grid.Column="0"
Text="Preference_Save"
Clicked="PreferenceSaveButton_Clicked"/>
<Button x:Name="PreferenceReadButton"
TextTransform="None"
Grid.Row="1"
Gri