SQLiteDatabase中query、insert、update、delete方法参数说明

来源:互联网 发布:java开发百度云播放器 编辑:程序博客网 时间:2024/06/08 12:25

private SQLiteDatabase db;
private MySQLite myDB;
//初始化
myDB= new MySQLite (this);
db = myDB.getWritableDatabase();

1、query

ContentValues cv = new ContentValues();
String[] args = {String.valueOf(“a”)};

db.query(“user”, new String[] { “username”,”password” },”username=?”, args, null,null, null, null)

2、insert

ContentValues cv = new ContentValues();
cv.put(“username”, “a”);
cv.put(“password”, “b”);
db.insert(“user”, null, cv);

3、update

ContentValues cv = new ContentValues();
cv.put(“username”, “c”);
cv.put(“password”, “d”);
String[] args = {String.valueOf(“a”)};
db.update(“user”, cv, “username=?”,args)

4、delete

ContentValues cv = new ContentValues();
String[] args = {String.valueOf(“c”)};
db.delete(“user”, “username=?”, args);

阅读全文
0 0
原创粉丝点击