AI智能
改变未来

Android sqlite SQL语句

//创建数据库:

String sql = “create table person(id integer primary key autoincrement,name varchar(64),address varchar(64))”;

//插入:
database = helper.getWritableDatabase();//实现对数据库写的操作
String sql = “insert into person(name,address,sex) values(?,?,?)”;
database.execSQL(sql, params);

//删除:

String sql = “delete from person where id = ?”;

database = helper.getWritableDatabase();

database.execSQL(sql, params);

//查询:
String sql = “select * from person where id = ?”;//通过id查询
database = helper.getReadableDatabase();
cursor = database.rawQuery(sql, selectionArgs);//Cursor:是每一行的集

String sql = “select * from person”;//获取全部联系人
SQLiteDatabase database = null;
database = helper.getReadableDatabase();
cursor = database.rawQuery(sql, selectionArgs);

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » Android sqlite SQL语句