SQLiteDataBase的增删改查方法参数
来源:互联网 发布:js获取来源url 编辑:程序博客网 时间:2024/05/17 22:53
1、SQLiteDataBase对象的query()接口:
public Cursor query (String table, String[] columns, String selection, String[] selectionArgs,
String groupBy, String having,String orderBy,String limit)
table The table name to compile the query against.(要查询的表名.)columns A list of which columns to return. Passing null will return allcolumns, which is discouraged to prevent reading data from storagethat isn't going to be used.(想要显示的列,若为空则返回所有列,不建议设置为空,如果不是返回所有列)selection A filter declaring which rows to return, formatted as an SQL WHEREclause (excluding the WHERE itself). Passing null will return allrows for the given table.(where子句,声明要返回的行的要求,如果为空则返回表的所有行。)selectionArgs You may include ?s in selection, which will be replaced by thevalues from selectionArgs, in order that they appear in theselection. The values will be bound as Strings.( where子句对应的条件值)groupBy A filter declaring how to group rows, formatted as an SQL GROUP BYclause (excluding the GROUP BY itself). Passing null will cause therows to not be grouped.(分组方式,若为空则不分组.)having A filter declare which row groups to include in the cursor, if rowgrouping is being used, formatted as an SQL HAVING clause(excluding the HAVING itself). Passing null will cause all rowgroups to be included, and is required when row grouping is notbeing used.(having条件,若为空则返回全部(不建议))orderBy How to order the rows, formatted as an SQL ORDER BY clause(excluding the ORDER BY itself). Passing null will use the defaultsort order, which may be unordered.(排序方式,为空则为默认排序方式)limit Limits the number of rows returned by the query, formatted as LIMITclause. Passing null denotes no LIMIT clause.(限制返回的记录的条数,为空则不限制)
Query the given table,returning a Cursor
overthe result set.
Parameters
Returns
- A
Cursor
object,which is positioned before the first entry. NotethatCursor
sare not synchronized, see the documentation for more details.
示例:
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)
Convenience method forinserting a row into the database.
Parameters
null
.SQL doesn't allow inserting a completely empty row without namingat least one column name. If yourprovided values
isempty, no column names are known and an empty row can't beinserted. If not set to null, the nullColumnHack
parameterprovides the name of nullable column name to explicitly insert aNULL into in the case where your values
isempty.( 当values参数为空或者里面没有内容的时候,我们insert是会失败的(底层数据库不允许插入一个空行),为了防止这种情况,我们要在这里指定一个列名,到时候如果发现将要插入的行为空行时,就会将你指定的这个列名的值设为null,然后再向数据库中插入。)Returns
- the row ID of the newly insertedrow, or -1 if an error occurred
示例:
ContentValues cv =
new
ContentValues();
cv.put(
"username"
,
"a");cv.put(
"password"
,
"b");insert("user",
null
,cv);
3、SQLiteDataBase对象的update()接口:
publicint update (String table, ContentValues values, String whereClause, String[] whereArgs)
Convenience method for updatingrows in the database.
Parameters
whereArgs
the group of args to dealwith(whereClause语句中表达式的?占位参数列表)
Returns
- the number of rows affected
ContentValues cv =
new
ContentValues();
cv.put(
"username"
,
"c");cv.put(
"password"
,
"d");String[] args = {String.valueOf("a")};
update("user",cv,
"username=?"
,args)
4、SQLiteDataBase对象的delete()接口:
publicint delete (String table, String whereClause, String[] whereArgs)
Convenience method for deletingrows in the database.
Parameters
whereArgs
the optional WHERE clauseto apply when updating. Passing null will update allrows.(whereClause语句中表达式的?占位参数列表)
Returns
- the number of rows affected if awhereClause is passed in, 0 otherwise. To remove all rows and get acount pass "1" as the whereClause.
示例:
ContentValues cv =
new
ContentValues();
String[] args = {String.valueOf("c")};
delete("user",
"username=?"
,args);
0 0
- SQLiteDataBase的增删改查方法参数
- SQLiteDatabase的增删查改
- 关于数据库SQLiteDatabase的增删改查四个方法的参数详解
- SQLiteDatabase 增删改查参数说明
- Android SQLiteDataBase的另一种增删改查
- SQLiteDatabase(数据库的增删改查)
- 赵雅智_使用SQLiteDatabase提供的增删改查方法及事务
- Android对SQLite的"增删改查"——SQLiteDatabase
- ContentProvider-SqliteDatabase实现增删查改(1)
- SqliteDatabase 对多个表增删改查
- android(19)_数据存储与访问_SQLite数据库_使用SQLiteDatabase提供的增删改查方法
- 关于Android中SQLiteDataBase的增删改查的基本使用
- 数据库的增删改查方法
- ListView的增删改查等方法
- 安卓中数据库增删改查的方法
- 前台的增删改查方法
- MyBatis的增删改查方法
- ofbiz 简单的增删改查方法
- Intent和Bundle使用方法
- iOS:iOS8开发(三)~深入理解autolayout
- Java包装类
- LeetCode——Multiply Strings
- 黄金价格自两周高位回落收平 因日本经济低迷提振美元
- SQLiteDataBase的增删改查方法参数
- 最坏情况下的线性时间的选择算法
- 流程管理与流程快速开发平台设计思路
- 单例
- 多核CPU概念
- 项目总结-HttpURLConnection的disconnect的问题
- 210_loader_nandboot启动执行过程
- Android键盘输出增加按键码
- oracle学习——插入多行数据到表中