db.execSQL("create table person(_id integer primary key autoincrement, name char(10), salary char(20), phone integer(20))");
增
db.execSQL("insert into person (name, salary, phone)values(?, ?, ?)", new Object[]{"小志", 14000, "13888"});
删
db.execSQL("delete from person where name = ?", new Object[]{"小志"});
改
db.execSQL("update person set phone = ? where name = ?", new Object[]{186666, "小志的儿子"});
查
public void select(){
Cursor cursor = db.rawQuery("select name, salary from person", null);
while(cursor.moveToNext()){
//通过列索引获取列的值
String name = cursor.getString(cursor.getColumnIndex("name"));
String salary = cursor.getString(1);
System.out.println(name + ";" + salary);
}
}