Android SQLite之乐学成语项目数据库存储

时间:2024-04-06 22:35:48

一、SQLite是什么?为什么要用SQLite?SQLite有什么特点?(下面小编一 一解答)

①SQLite是一个轻量级的关系型数据库,运算速度快,占用资源少,很适合在移动设备上使用, 不仅支持 标准SQL语法,还遵循ACID(数据库事务)原则,无需账号,使用起来非 常方便!

②前面我们学习了使用文件与SharedPreference来保存数据,但是在很多情况下, 文件并不 一定是有效的,如多线程并发访问是相关的;app要处理可能变化的复杂数据结构等等! 比如银行的存钱与取钱!使用前两者就会显得很无力或者繁琐,数据库的出现可以解决这种问题, 而Android又给我们提供了这样一个轻量级的SQLite,为何不用?

③SQLite支持五种数据类型:NULL,INTEGER,REAL(浮点数),TEXT(字符串文本)和BLOB(二进制对象)虽然只有五种,但是对于varchar,char等其他数据类型都是可以保存的;SQLite有个最大的特点: 你可以各种数据类型的数据保存到任何字段中而不用关心字段声明的数据类型是什么,比如你 可以在Integer类型的字段中存放字符串,当然除了声明为主键INTEGER PRIMARY KEY的字段只能够存储64位整数!另外, SQLite 在解析CREATE TABLE 语句时, 会忽略 CREATE TABLE 语句中跟在字段名后面的数据类型信息如下面语句会忽略 name字段的类型信息: CREATE TABLE person (personid integer primary key autoincrement, name varchar(20))

二、几个相关的类

  • SQLiteOpenHelper:抽象类,我们通过继承该类,然后重写数据库创建以及更新的方法, 我们还可以通过该类的对象获得数据库实例,或者关闭数据库!
  • SQLiteDatabase:数据库访问类:我们可以通过该类的对象来对数据库做一些增删改查的操作
  • Cursor:游标,有点类似于JDBC里的resultset,结果集!可以简单理解为指向数据库中某 一个记录的指针!

三、SQLiteDdatabase相关的方法

  • execSQL(SQL,Object[]):使用带占位符的SQL语句,这个是执行修改数据库内容的sql语句用的
  • rawQuery(SQL,Object[]):使用带占位符的SQL查询操作 另外前面忘了介绍下Curosr这个东西以及相关属性,这里补充下: ——Cursor对象有点类似于JDBC中的ResultSet,结果集!使用差不多,提供一下方法移动查询结果的记录指针:
  • move(offset):指定向上或者向下移动的行数,整数表示向下移动;负数表示向上移动!
  • moveToFirst():指针移动到第一行,成功返回true,也说明有数据
  • moveToLast():指针移动到最后一样,成功返回true;
  • moveToNext():指针移动到下一行,成功返回true,表明还有元素!
  • moveToPrevious():移动到上一条记录
  • getCount( )获得总得数据条数
  • isFirst():是否为第一条记录
  • isLast():是否为最后一项
  • moveToPosition(int):移动到指定行

四、  代码实例

android的数据库放在/data/data/package name/目录下,所以我们需要做的是把自己已有的数据库传入那个目录下,思路是用FileInputStream读取数据库,再用FileOutputStream把读到的东西写入那个目录。这样就可以方便的操作数据库了。

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import com.bzu.qilu.R;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.Environment;
import android.util.Log;
/**数据库管理类
* @author 刘齐鲁
*date 2016-5-20
*/ public class DBOpenHelper {
private final int BUFFER_SIZE = 400000;//缓冲区大小
public static final String DB_NAME="idioms.db";//保存的数据库文件名
public static final String PACKAGE_NAME="com.bzu.qilu";//应用包名
public static final String DB_PATH="/data"
+ Environment.getDataDirectory().getAbsolutePath()+"/"
+ PACKAGE_NAME+"/databases";//在手机里存放数据库的位置
private Context context;
public DBOpenHelper(Context context){
this.context=context;
}
//打开数据库
public SQLiteDatabase openDatabase(){
try{
File myDataPathFile = new File(DB_PATH);//
if(!myDataPathFile.exists()){
myDataPathFile.mkdir();//如果没有这个目录则创建
}
String dbfile = myDataPathFile+"/"+DB_NAME;
if(!(new File(dbfile).exists())){
//判断数据库文件是否存在,若不存在则执行导入,否则直接打开数据库
InputStream is = context.getResources().openRawResource(R.raw.idioms);
FileOutputStream fos = new FileOutputStream(dbfile);
byte[] buffer = new byte[BUFFER_SIZE];
int count = 0;
while((count =is.read(buffer))>0){
fos.write(buffer,0,count);
}
fos.close();
is.close();
}
SQLiteDatabase db =SQLiteDatabase .openOrCreateDatabase(dbfile, null);
return db;
}catch(FileNotFoundException e){
Log.e("Database", "File not found");
e.printStackTrace();
}catch(IOException e){
Log.e("Database", "IO exception");
e.printStackTrace();
}
return null;
}
}

编写测试程序:

public class DBOpenHelperTest extends AndroidTestCase {
public void testDBCopy(){
DBOpenHelper dbOpenHelper = new DBOpenHelper(getContext());
dbOpenHelper.openDatabase();
}
}

会出现下面界面:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXAAAAFuCAIAAAAXp9SDAAAcS0lEQVR4nO3daXAU553H8SnKr/wmL5JyratSRbli15Z3K4vLqawTkYAxJEVCMCZxst5lDWxcEC8GHGMZQwwyjrCBWBgQl8whG4wuY8wIhBDXSj0WVyBI4AMBQiAui2MkIXSMZkb0vhipNepremb+oxnE91P/UjU93U8//XT3Tz09knDVX2unKIoSKVfp/uMURVEi5brVGqQSV6qqhgZaHShCu5P0gaVSs1xXmzqpBFXo8kt2AiRE6f7jSR9eKgXLVXejjUpQDdQ0CSndfzzpI0ylWrlOX22hElHqwL09CSndfzzpg0ylWrmqLzRSiaiBnSYhpfuPJ32cqZQqAiVRRaBQ92H1CZRXZy9MeocGTBEo1H1Yrqq6Rq1enb1Qm1b+8sMvMoZm/+6RLzKGfpExNHwxykndJ4GS9HGmqi7o62lbxuVtKrrV66wD5cDsf/W37131wuP+9r3lc39qsTM7J7o0IzO+cD4KOydGt7zDNntNzE9iTxqrrANlfXnR+PWvazV72wcOrtzydNfoDRfDJ3TzzVzcMNrm1b600yXizHAESmqWzSF7+umno21KHyi2y+sDRauVvx+86oXH/zz0n1a98Hj27x6xWL/3aty1aKRr2IpdTjuaoECJoc3+DpSQ8etff2ThuGV7Njm63GMLFJPVLWmnoM2EEYGSmiUbKFGt7jpx3qvVq7MXatPFL/+zdoey45UnwxcLq+KJrhEZHuN0xIpq4YS2mYieeE+c996jgaL23JiYvqRTuv+4+LhR0ZZpCti95XEcJTpqpEA5cd5rGShb/+fRbVOGrHrh8W1ThmybMsRiZ8wDZd2UnjceU4p7lqzOGNbzZiQvfOHiiT2LmazlWZ7mcrlcrrR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585Stfpb4mP1AADBgECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAxBAoAMQQKADEECgAx/w8QP36AeQC+3gAAAABJRU5ErkJggg==" alt="" width="368" height="188" />

我们在这个FileExplorer目录下找到数据库存放的位置

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjcAAAEDCAIAAABGSbLfAAAOsElEQVR4nO3dT4sl13kH4P4aWRiyMHjhxYAWwp8jX8C7kIAWYVZaGGw8yB5QsP7YEopsK56g2ANyKzOysAOR4mBBMHjhgdgwGMdWwEQTYZlhFM3cUQvKi5Fad26dOnWqbt2q99x6HgpRU13n1Lnd1efXp1u33pNmlJf++nOZbVyfALDjZOkBAEAnKQVAXFIKgLikFABxSSkA4pJSAMQ1PqXeevLR823CAQHAuZOmab7SravZ6WOfzfyz6MInJycnVnIA5HycUsmPdR1/64lHN7de2Nx64fbNp2/duPz2fzx+89rfvfXEo9tb0bWzKSXDABiTUm888cjm9s8z2xtPPFJ0bSkFQNaolPryI5tb1zLbS1/8y56rfmLnSOaE9jkAHL1PU+rkYU13Sr3+5Uc2b3/vfDu9eCGzJS75SdJkdprWWip5DgDHbcxa6vTi5zc3n36wnV68sHn7heR268blwpRqOlZX7YaWUwCrMial/vmxz25uXt7cvHx68cKDnfbWFVGNtRQAxcak1Etf/MzmxuOnFy9sbnwluWUi6uOrPvyrxeSRpvuPVYIKYCXGvF/qqb/6i9OLFzY3Hk9uvREFAIVGLkpUQQRgBn51BkBcUgqAuKQUAHFJKQDiklIAxCWlAIhrgZRSPhGAQnul1CLlEwFYj31TatDxqconArASk6XU9rP1Dl0+EYCVmDelJiqfuL3f+8haAOo1QUqFKp+owAfAMZl1LbVn+cSmVQhRSgEct1lTaobyiVIK4JjM+v/4TV4+satwoogCOA6zvl9q8vKJ7TSSTwDHZO45fcLyiRZSAEfPhA5AXFIKgLikFABxSSkA4pJSAMQlpQCISxVEAOJSBRGAuFRBBCAuVRABiOvIqyC2a1+1+0k2bJ/TeAITwOzWWAWx5ORxPQMwrZVWQRyxuhJOAPNbYxXEQUuo5AsEYB4rrY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69/b9Ky9/J9O262uZ+ZIkv4qZr2jvpTM7lItzQ8Ky8qul9vH2dJeflKTUYN++cuV//3T/ndb24OC3r1zJtD1QSjUF/zeElJpWnBsSFpSOkIEp1aSKFvVcYo8xH0qcSeG57778hz+m11J/+OP957/7cqbt4VIq2TZ/LSm1jzg3JCwln0Zd++XTXeYqEeesOJPC0y9e/Z93N13b0y9e7WqY/DtQ+yeIrnPO95vWFzv/m99B16JQnBsSlnLysJ2D7dMyR7aP58/5+KNTvo6JxJkUnnz+ld//32ZnFfX7W/d+d+ve725tnnz+laUHyBzi3JCwQlIq52vfevW379z77Tv3/vvh/z7Y+fo3X116gMwhzg0JKySlci49c/3Ss9cvPXvtq89ce7Dzyf61S89cv/TMtaUHyBzi3JCwQlIKerghYUFBU8pmC7Ut/T0B6xUxpQDgASmVowoiwLKkVI4qiADLklI5qiACLEtK5aywCuIMz6fwIAw4Vl0Pp2g/B6fuZ0/EoQri4QQcErCP9o/gyQcj9e7sNpl2lEdGFcTDCTgkYB8lKdU+uXcqMFPkHGsVxOSiOzmk5IB7d/L9nB/JjB+oV34Sa1p5lp/TzBQ5K6yCmBxefqf3lZa8duA4dIZNtsZHpq2ZImeFVRBHpFTv1c/HLKXguGW+r6XUQaywCuIhUspaCtYgP01JqYNYYRXEzHjaPSdXSDsXzbQqHBJQheS3dtdEl2yY7vZAwz0OK6yCKDaAUExJOeupgmhlA8RkVspRBRFgWVIKgLikFABx/RkuX3PzBa1KZwAAAABJRU5ErkJggg==" alt="" width="567" height="206" />

我们发现数据库有两个,前者是我们创建的数据库,而后者则是为了能让数据库支持事务而产生的 临时的日志文件!一般的大小是0字节! 而在File Explorer里我们确是打不开文件的。所以下面给大家介绍两个方法:

  • 1.先导出来,然后用SQLite的图形化工具查看
  • 2.配置adb环境变量后,通过adb shell来查看(命令行,装比利器)!