要求:
1.实验报告要完整,即要有实验要求与目的、实验内容与步骤(必要流程图或活动图、代码)、运行结果与分析、实验体会与收获;
2.代码要有必要的注释;
3.标题为四号黑体,其他为宋体小四号,行间距为单倍行间距,纸张大小为A4;
4.考核项目
考核项目 |
格式与完成性 |
实验内容 |
实验结果与分析 |
实验体会与收获 |
总成绩 |
权重 |
20% |
60% |
10% |
10% |
100% |
得分 |
-
实验目的
1.熟悉数据存储方式,能够归纳五种数据存储方式的特点;
2.掌握文件存储方式的使用,能够实现使用文件存储数据的功能;
3.掌握SharedPreferences的使用,能够实现数据存储的功能;
4.掌握SQLite数据库的使用,能够实现数据的增删改查功能。
- 实验工具
Android studio。
-
实验内容
运行效果图如下:
- 完成上图的布局;
- 利用SQLite数据库的创建与增删改查操作,完成上图添加、删除、修改、查询通讯录内容:姓名、电话。
-
实验过程(代码)
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
android:orientation="vertical"
android:padding="16dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="130dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名:"
android:textSize="18sp"/>
<EditText
android:id="@+id/et_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入姓名"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text