Xamarin 跨平台应用开发(5)——本地存储

本文介绍了Xamarin应用开发中两种本地存储方法:偏好存储和本地数据库。偏好存储用于存储少量临时数据,而本地数据库则使用sqlite-net-pcl包。在使用本地数据库时,需要注意文件路径的格式问题,推荐使用System.IO.Path.Combine来组合路径。调试时,可以使用UWP项目,并借助DB Browser工具查看.db文件。
摘要由CSDN通过智能技术生成

本节顺序与内容参考了,张引的《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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值