参考:http://blog.csdn.net/jianghuiquan/article/details/8569252

在Android平台上,集成了一个嵌入式关系型数据库—SQLite。以SQLite是一款轻型数据库:SQLite3支持 NULL、INTEGER、REAL(浮点数字)、TEXT(字符串文本)和BLOB(二进制对象)数据类型,虽然它支持的类型只有五种,但实际上sqlite3也接受varchar(n)、char(n)、decimal(p,s) 等数据类型,只不过在运算或保存时会转成对应的五种数据类型。

  SQLite可以解析大部分标准SQL语句。

一、设计界面

  1、布局文件

  打开activity_main.xml文件。
  输入以下代码:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EFEFEF"> <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/prompt"
android:textColor="@drawable/black" /> <EditText
android:id="@+id/editbook"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@drawable/black" /> <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="作者:"
android:textColor="@drawable/black" /> <EditText
android:id="@+id/editauthor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@drawable/black" /> <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="出版社:"
android:textColor="@drawable/black" /> <EditText
android:id="@+id/editpublisher"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@drawable/black" /> <ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/black" /> </LinearLayout>

2、自定义列表文件

  打开list.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"> <CheckedTextView android:id="@+id/textbookname"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /> <ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/list_drive1" />
<CheckedTextView android:id="@+id/textauthor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/> <ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/list_drive1" /> <CheckedTextView android:id="@+id/textpublisher"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /> </LinearLayout>

color.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="black">#000000</drawable>
<drawable name="list_drive">#00000FFF</drawable>
<drawable name="white">#FFFFFFFF</drawable>
<drawable name="gray">#EFEFEF</drawable>
</resources>

 

string.xml

<resources>
<string name="app_name">My</string> <string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="prompt">书名:(请使用菜单:完成新增、修改、查询、刪除记录)</string>
<string name="addrec">新增</string>
<string name="editrec">修改</string>
<string name="queryrec">查询</string>
<string name="delrec">刪除</string>
</resources>

Android 使用SQLite本地数据库的更多相关文章

  1. Android应用查看本地数据库

    使用Android Studio 视图==>工具窗口 == >Device File Explorer ==> 文件在 data/data目录下,你的应用程序报名,右键save as ...

  2. Android版本更新之本地数据库更新

    最近上架了一个算法学习类APP,在更新应用版本时,发现数据库依旧没有更新,还是上一个版本的数据内容,遂把这方面的内容记录下来. PS:本人处女作APP <算法之家> 可以在豌豆荚.360手 ...

  3. Xamarin android使用Sqlite做本地存储数据库

    android使用Sqlite做本地存储非常常见(打个比方就像是浏览器要做本地存储使用LocalStorage,貌似不是很恰当,大概就是这个意思). SQLite 是一个软件库,实现了自给自足的.无服 ...

  4. [转载]Unity3D 游戏引擎之使用C#语言建立本地数据库(SQLITE)

    以前在开发中一直使用IOS源生的数据库,通过传递消息的形式在与Unity3D中进行交互.本文我在详细说说如何使用C#语言来在MAC 操作系统下创建Unity本地数据库,我是C#控哇咔咔--- 首先你需 ...

  5. Xamarin.Forms 使用本地数据库之 SQLite

    前言 Xamarin.Forms支持使用SQLite数据库引擎.本文介绍了Xamarin.Forms应用程序如何读取和写入数据到使用SQLite.Net的本地SQLite数据库. 在Xamarin.F ...

  6. Android实现SQLite数据库的增、删、改、查的操作

    核心代码DAO类 package com.examp.use_SQLite.dao; import java.util.ArrayList; import java.util.List; import ...

  7. Xamarin.Android 使用 SQLiteOpenHelper 进行数据库操作

    一.前言 在手机中进行网络连接不仅是耗时也是耗电的,而耗电却是致命的.所以我们就需要数据库帮助我们存储离线数据,以便在用户未使用网络的情况下也可以能够使用应用的部分功能,而在需要网络连接的功能上采用提 ...

  8. Android本地数据存储之SQLite关系型数据库 ——SQLiteDatabase

    数据库的创建,获取,执行sql语句: 框架搭建:dao 思考: 1.数据库保存在哪里? 2.如何创建数据库?如何创建表? 3.如何更新数据库?如何更改表的列数据? 4.如何获取数据库? 5.如何修改数 ...

  9. Android中SQLite数据库小计

    2016-03-16 Android数据库支持 本文节选并翻译<Enterprise Android - Programing Android Database Applications for ...

随机推荐

  1. nyoj 题目49 开心的小明

    开心的小明 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 小明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间.更让他高兴的是,妈妈昨天 ...

  2. jQuery选择器示例

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. js获取页面元素位置函数(跨浏览器)

    function getElementPos(elementId) { var ua = navigator.userAgent.toLowerCase(); var isOpera = (ua.in ...

  4. js中prop和attr区别

    首先 attr 是从页面搜索获得元素值,所以页面必须明确定义元素才能获取值,相对来说比较慢. 如: <input name='test' type='checkbox'> $('input ...

  5. 如何禁用Eclipse的Validating

    使用Eclipse开发项目,在加载项目.刷新项目.修改了某个代码的时候,经常出现Eclipse正在Validating的提示.项目比较大文件(js)较多的情况下,甚至出现Validating几分钟的盛 ...

  6. c#后的完整cookie

    http://www.cnblogs.com/top5/archive/2010/04/11/1709457.html c#设置 webbrowser的请求cookie,可以通过fiddler分析co ...

  7. Pandas之Series

    # Series 数据结构 # Series 是带有标签的一维数组,可以保存任何数据类型(整数,字符串,浮点数,Python对象等),轴标签统称为索引 import numpy as np impor ...

  8. 浅谈_IDEA导入Eclipse的Web项目

    相信很多同学在工作中都会遇到将一个Eclipse的Web项目导入IDEA的情景,这里浅谈一下具体的操作流程 一:Import Project,选择要导入的项目 二:选择以Eclipse模型的方式导入 ...

  9. PriorityQueue详解(一)

    在Java SE 5.0中,引入了一些新的Collection API,PriorityQueue就是其中的一个.今天由于机缘巧合,花了一个小时看了一下这个类的内部实现,代码很有点意思,所以写下来跟大 ...

  10. gdb 调试打印

    gdb查看指定地址的内存地址的值:examine 简写 x-----使用gdb> help x 来查看使用方式 x/ (n,f,u为可选参数) n: 需要显示的内存单元个数,也就是从当前地址向后 ...