- SQLiteDatabase db = dbBookStoreHelper.getWritableDatabase();
- //新建两个数据
- db.execSQL("insert into Book (name, author, pages, price) values(?, ?, ?, ?)", new String[] {
- "The Da Vinci Code",
- "Dan Brown",
- "454",
- "16.96"
- });
- db.execSQL("insert into Book (name, author, pages, price) values(?, ?, ?, ?)", new String[] {
- "The Lost Symbol",
- "Dan Brown",
- "510",
- "19.95"
- });
- //查询所有数据
- db.rawQuery("select * from Book", null);
- //把《The Da Vinci Code》这本书改成10.99
- db.execSQL("update Book set price = ? where name = ?", new String[] {
- "10.99",
- "The Da Vinci Code"
- });
- //把500页以上的书删了
- db.execSQL("delete from Book where pages > ?", new String[] {
- "500"
- });
来源: