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

1、SQLiteDataBase对象的query()接口
public Cursor query (String table, String[] columns, String selection, String[] selectionArgs,String groupBy, String having,String orderBy,String limit)
示例:
ContentValues cv = new ContentValues();
String[] args = {String.valueOf("a")};
query("user",new String[] { "username","password" },"username=?", args,null,null,null, null);


2、SQLiteDataBase对象的insert()接口:

publiclong insert (String table, String nullColumnHack, ContentValues values)
示例:
ContentValues cv = new ContentValues();
cv.put("username", "lanxiaofang");
cv.put("password", "123456");
insert("user", null,cv);


3、SQLiteDataBase对象的update()接口:

publicint update (String table, ContentValues values, String whereClause, String[] whereArgs)
示例:
ContentValues cv = new ContentValues();
cv.put("username", "lanxiao");
cv.put("password", "123456");
String[] args = {String.valueOf("lanxiaofang")};
update("user",cv, "username=?",args)


4、SQLiteDataBase对象的delete()接口:

publicint delete (String table, String whereClause, String[] whereArgs)
示例:
ContentValues cv = new ContentValues();
String[] args = {String.valueOf("lanxiaofang")};
delete("user", "username=?",args);


下面是个人的微信公众号,期待您的关注!!!




你可能感兴趣的:(数据库)