SQLite的封装类
package
{
import flash.data.SQLConnection;
import flash.data.SQLResult;
import flash.data.SQLStatement;
import flash.errors.SQLError;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
import flash.filesystem.File;
import mx.collections.ArrayCollection;
public class DBUtil
{
/**
* 数据库操作类别
**/
private const typeArr:Array = ['select','insert','update','delete','create','alter','drop'];
/**
* 连接
**/
private var conn:SQLConnection;
/**
* 声明
**/
private var stmt:SQLStatement;
/**
* 结果集合
**/
private var rsAC:ArrayCollection;
public function DBUtil()
{
}
/**
* 获得连接
**/
private function getConn():SQLConnection
{
if(this.conn == null){
conn = new SQLConnection();
conn.addEventListener(SQLEvent.OPEN, sqlOpen);
conn.addEventListener(SQLErrorEvent.ERROR, sqlError);
}
return this.conn;
}
/**
* 关闭连接
**/
private function closeConn():void
{
if(this.conn != null){
this.conn.close();
this.conn = null;
}
}
/**
* 获得声明
**/
private function getStatement():SQLStatement
{
if(this.stmt == null)
{
stmt = new SQLStatement();
stmt.sqlConnection = getConn();
stmt.addEventListener(SQLErrorEvent.ERROR, sqlError);
}
return this.stmt;
}
/**
* 关闭声明
**/
private functio
相关文档:
sqlite数据库第三方java扩展包下载地址:http://www.zentus.com/sqlitejdbc/
有2个包,一个是nested(嵌入式的),一个是native(本地的)。
区别在于:nested 不需要额外的dll文件,但是速度慢。native需要一个额外的dll文件,速度很快。
1.使用nested包:sqlitejdbc-v037-nested.jar
java代码:
java 代码
packa ......
/*=================================
.* The Standard include file.
.*
.*===============================*/
#include <stdio.h>
#include <stdlib.h>
/*=================================
.*
.* The extend include file.
.*
.*===============================*/
#include "sqlit ......
先记下来:
FileOutputStream outputStream = openFileOutput("mydb", 0);
InputStream inputStream = response.getEntity().getContent();
byte[] data = new byte[bufferSize];
for (int i = inputStream.read(data); i > 0; i = inputStream
.read(data)) {
& ......
前两篇日志我已经总结了本地数据存储的前两种:文件和配置项。还剩下最后一种数据库存储——SQLite。
一、SQLite简介
在Android平台上,集成了一个嵌入式关系型数据库—SQLite,SQLite3支持 NULL、INTEGER、REAL(浮点数字)、TEXT(字符串文本)和BLOB(二进制对象)数据类型,虽然它支持的类型虽然只有五种 ......
Android SQLite Database本打算封装SQLite的,但是,发现实际上Android已经封装了一层,尤其是数据的增、删、查、改上,更是如此,所以,我后来只封装了一个连接层,负责打开、建立数据库,并返回一个SQLite的实例用来完成增、删、插、改等操作。
//----------- DBHelper -------------
package utility.db;
import ja ......