参考: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. lua中是 ffi 解析 【是如何处理数据包的/pkt是如何传进去的】 fsfsfs

    lua中的ffi是如何解析的呢? 拿bcc中对proto的解析说起: metatype是有大学问的: ffi.metatype(ffi.typeof('struct ip_t'), { __index ...

  2. [2018-9-4T2]探索黑暗dark

    题目大意:有一棵树,第$i$个点的点权为$s_i(s_1>0)$.初始有每个点都是亮的.$m$次修改,每次改变一个点的亮暗,回答包含$1$的全亮的连通块中点权和最大的连通块的和的值. 题解:正解 ...

  3. POJ A Simple Problem with Integers | 线段树基础练习

    #include<cstdio> #include<algorithm> #include<cstring> typedef long long ll; #defi ...

  4. oracle怎么查看一个表或一个索引占用多少空间

    很多时候我们想知道一个表或一个索引占用多少M的空间,以下脚本就是满足这个要求的,记住替换其中的内容. SELECT owner, segment_name, SUM(bytes)/1024/1024 ...

  5. Linux下目录的权限详解

    在Linux文件系统模型中,每个文件都有一组9个权限位用来控制谁能够读写和执行该文件的内容.普通文件大家都了解,这里说说目录的情况. 对于目录来说,执行位的作用是控制能否进入或者通过该目录,而不是控制 ...

  6. Python-Python及PyCharm的下载与安装

    一.简介 Python:英 -[‘paɪθ ə n]或[‘paɪθɑn] 89年诞生 可用于软件开发: 游戏后台.搜索.图形界面 网站 C\S(Client/Server)软件 科学计算 亦可以进行系 ...

  7. 自定义View Layout过程 (3)

    目录 目录 1. 知识基础 具体请看我写的另外一篇文章:(1)自定义View基础 - 最易懂的自定义View原理系列 2. 作用 计算View视图的位置. 即计算View的四个顶点位置:Left.To ...

  8. Linux网络编程一步一步学【转】

    转自:http://blog.chinaunix.net/uid-10747583-id-297982.html Linux网络编程一步一步学+基础  原文地址:http://blogold.chin ...

  9. [Oracle] Transporting Tablespace

    Transporting Tablespace Between Database [测试目的] 利用Oracle TTS(transport tablespace)特性实现表空间合并 [主要步骤] 确 ...

  10. ubuntu默认用户分析

    harvey@ubuntu:/etc$ cat -b passwd root:x:::root:/root:/bin/bash daemon:x:::daemon:/usr/sbin:/bin/sh ...