1、什么是SQLite
2、Android中使用SQLite
一、什么是SQLite
SQLite是一款开源的、轻量级的、嵌入式的、关系型数据库。它在2000年由D. Richard Hipp发布,、PHP、Ruby、Python、Perl、C等几乎所有的现代编程语言,支持Windows、Linux、Unix、Mac OS、Android、IOS等几乎所有的主流操作系统平台。
SQLite被广泛应用的在苹果、Adobe、Google的各项产品。如果非要举一个你身边应用SQLite的例子的话,如果你的机器中装的有迅雷,请打开迅雷安装目录,,是不是找到了它的身影? 如果你装的有金山词霸,。是的,SQLite早就广泛的应用在我们接触的各种产品中了,当然我们今天学习它,是因为在Android开发中,Android推荐的数据库,也是内置了完整支持的数据库就是SQlite。
SQLite的特性:
1. ACID事务
2. 零配置–无需安装和管理配置
3. 储存在单一磁盘文件中的一个完整的数据库
4. 数据库文件可以在不同字节顺序的机器间自由的共享
5. 支持数据库大小至2TB
6. 足够小, 大致3万行C代码, 250K
7. 比一些流行的数据库在大部分普通数据库操作要快
8. 简单, 轻松的API
9. 包含TCL绑定, 同时通过Wrapper支持其他语言的绑定
10. 良好注释的源代码, 并且有着90%以上的测试覆盖率
11. 独立: 没有额外依赖
12. Source完全的Open, 你可以用于任何用途, 包括出售它
13. 支持多种开发语言,C, PHP, Perl, Java, ,Python
推荐的SQLite客户端管理工具,火狐插件 Sqlite Manger
二、Android中使用SQLite
我们还是通过一个例子来学习,相关讲解都写在代码注释里。
1、新建一个项目Lesson15_HelloSqlite,
2、编写用户界面 res/layout/,准备增(insert)删(delete)改(update)查(select)四个按钮,准备一个下拉列表spinner,显示表中的数据。
<?xml version="" encoding="utf-8"?>
<linearlayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" xmlns:android="http://schemas./apk/res/android">
<textview android:layout_height="wrap_content" android:layout_width="wrap_content" android:textsize="20sp" android:layout_margintop="5dp" android:id="@+id/TextView01" android:text="SQLite基本操作">
</textview>
<button android:layout_height="wrap_content" android:layout_width="wrap_content" android:textsize="20sp" android:layout_margintop="5dp" android:id="@+id/Button01" android:text="增| insert" android:minwidth="200dp"></button>
<button android:layout_height="wrap_content" android:layout_width="wrap_content" android:textsize="20sp" android:layout_margintop="5dp" android:id="@+id/Button02" android:text="删| delete" android:minwidth="200dp"></button>
<button android:layout_height="wrap_content" android:layout_width="wr
androidSQLLITE开发指南 来自淘豆网m.daumloan.com转载请标明出处.