创建表:db.execSQL("create table shoucang ( _id INTEGER PRIMARY KEY AUTOINCREMENT,title varchar(20),pic varchar(20),path varchar(20))");
添加的语句:db.execSQL("insert into toutiao (type,title) values (?,?)",new String[]{type,title});
删除的语句:db.execSQL("delete from shoucang where title = ?",new String[]{title});
修改的语句:db.execSQL("update toutiao set type = ? where title = ?",new String[]{type,title});
查询的语句:Cursor query = db.query("toutiao", null, null, null,null,null,null);
按条件查询全部:Cursor query = db.query("toutiao", null, "type=?", new String[]{tiaojian},null,null,null);
模糊查询并且降序:sql = "select * from house where price_address like '%"+pri+"%' order by price asc";
Cursor house = db.rawQuery(sql, null);
模糊查询并且升序:sql = "select * from house where price_address like '%"+pri+"%' order by price desc";
Cursor house = db.rawQuery(sql, null);
SQLite的简单使用
最新推荐文章于 2024-04-30 14:08:57 发布