安卓数据库案例

Sqllite

1、自定义创建数据库类纸 Fsqlliteopenhelper

2、初始化数据库

3、操作数据库

方法名称 方法表示含义
openorCreateDatabase(String path, SQLiteDatabase Cursor Factory factory) 打开或创建数据库

insert(string table, String nullColumnHack, Contentvalues values) 插入一条记录

delete(String table, String whereClause Stringl whereArgs) 删除一条记录

query(String table, Stringl columns, String selection, String selecuionArgs, String 查询一条记录
groupBy, String having, String orderBy)

update(String table Contentvalues values, String whereClause Stringl whereArgs) 修改记录

execsQL(String sql) 一执行一条SQL语句

closed() 关闭数据

Cursor常用方法

getcounto)获得总的数据项数

isFirsto判断是否第一条记录

isLasto判断是否最后一条记录

moveToFirst()移动到第一条记录

moveToLast()移动到最后条记录

move(int offset)移动到指定记录

movetonext() 移动到下一条记录

moveToprevious()移动到上一条记录

getColumnindexOrthrow (string columnName)根据列名称获得列引

getint(Columnindex)获得指定列引的nt类型值

getstring(int Columnindex)获得指列 String类型值

contentValues

猜你喜欢

转载自blog.51cto.com/14589602/2650737
今日推荐