Android数据存储

Android数据存储


前言

1、实验目的和要求
(1)掌握数据存储方法
(2)熟悉使用SD卡存储和手机内存存储数据的过程
(3)掌握SQLite数据库的使用方法
2、实验内容和原理
实现数据的内部存储和外部存储

一、实现数据的内容存储和外部存储

二、使用步骤

1.界面布局

activity_main代码如下(示例)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
    android:id="@+id/LL1"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginTop="64dp"
    android:orientation="horizontal">
     <Button
        android:id="@+id/bt1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:onClick="SP"
        android:text="SP存储" />
</LinearLayout>

<LinearLayout
    android:id="@+id/LL2"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_below="@+id/LL1"
    android:orientation="horizontal">

    <Button
        android:id="@+id/bt2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:onClick="NBCC"
        android:text="内部存储" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:orientation="horizontal"
    android:layout_below="@+id/LL2">
    <Button
        android:id="@+id/bt3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:onClick="WBCC"
        android:text="外部存储" />
</LinearLayout></RelativeLayout>

activity_wbcc代码如下(示例):

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/b"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="30dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tv1"
            android:layout_width="1dp"
            android:layout_height="58dp"
            android:layout_weight="0.4"
            android:text="外部SD存储"
            android:layout_marginLeft="15dp"
            android:textSize="20sp" />

    </LinearLayout>
    <LinearLayout
        android:id="@+id/a"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="90dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tv_phone"
            android:layout_width="wrap_content"
            android:layout_height="26dp"
            android:layout_weight="0.4"
 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

啥也不是的小赵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值