sqlite DatabaseUtils

来源:互联网 发布:淘宝二合一口令 编辑:程序博客网 时间:2024/05/29 14:31

This class allows users to do multiple inserts into a table but compile the SQL insert statement only once, which may increase performance.
此类允许用户对表进行多次插入,但是只编译一次SQL插入语句,这可能会提高性能。

1.public static final void writeExceptionToParcel(Parcel reply, Exception e)
Special function for writing an exception result at the header of a parcel, to be used when returning an exception from a transaction. exception will be re-thrown by the function in another process
用于在从事务中返回异常时使用的用于在包裹标头处写入异常结果的特殊函数。 异常将被另一个进程中的函数重新抛出

2.public static String sqlEscapeString(String value)

3.public static final void appendValueToSql(StringBuilder sql, Object value)

4.public static void cursorStringToContentValues(Cursor cursor,
String field,
ContentValues values)
从Cursor中的字段读取一个字符串,并将其写入InsertHelper。

5.public static void cursorStringToContentValues(Cursor cursor,
String field,
ContentValues values,
String key)
从游标中的字段读取字符串,并将其写入映射。

cursor - The cursor to read from
field - The TEXT field to read
values - The ContentValues to put the value into, with the field as the key
key - The key to store the value with in the map

cursorIntToContentValues
public static void cursorIntToContentValues(Cursor cursor,
String field,
ContentValues values)
Reads an Integer out of a field in a Cursor and writes it to a Map.
参数:
cursor - The cursor to read from
field - The INTEGER field to read
values - The ContentValues to put the value into, with the field as the key
cursorIntToContentValues

public static void cursorIntToContentValues(Cursor cursor,
String field,
ContentValues values,
String key)
Reads a Integer out of a field in a Cursor and writes it to a Map.
参数:
cursor - The cursor to read from
field - The INTEGER field to read
values - The ContentValues to put the value into, with the field as the key
key - The key to store the value with in the map

cursorLongToContentValues
public static void cursorLongToContentValues(Cursor cursor,
String field,
ContentValues values)
Reads a Long out of a field in a Cursor and writes it to a Map.
参数:
cursor - The cursor to read from
field - The INTEGER field to read
values - The ContentValues to put the value into, with the field as the key

cursorLongToContentValues
public static void cursorLongToContentValues(Cursor cursor,
String field,
ContentValues values,
String key)
Reads a Long out of a field in a Cursor and writes it to a Map.
参数:
cursor - The cursor to read from
field - The INTEGER field to read
values - The ContentValues to put the value into
key - The key to store the value with in the map
cursorDoubleToCursorValues
public static void cursorDoubleToCursorValues(Cursor cursor,
String field,
ContentValues values)
Reads a Double out of a field in a Cursor and writes it to a Map.
参数:
cursor - The cursor to read from
field - The REAL field to read
values - The ContentValues to put the value into

cursorDoubleToContentValues
public static void cursorDoubleToContentValues(Cursor cursor,
String field,
ContentValues values,
String key)
Reads a Double out of a field in a Cursor and writes it to a Map.
参数:
cursor - The cursor to read from
field - The REAL field to read
values - The ContentValues to put the value into
key - The key to store the value with in the map

cursorRowToContentValues
public static void cursorRowToContentValues(Cursor cursor,
ContentValues values)
Read the entire contents of a cursor row and store them in a ContentValues.
参数:
cursor - the cursor to read from.
values - the ContentValues to put the row into.

queryNumEntries
public static long queryNumEntries(SQLiteDatabase db,
String table)
Query the table for the number of rows in the table.
参数:
db - the database the table is in
table - the name of the table to query
返回:
the number of rows in the table、

longForQuery
public static long longForQuery(SQLiteDatabase db,
String query,
String[] selectionArgs)
Utility method to run the query on the db and return the value in the first column of the first row.
用于对数据库运行查询的实用方法,并返回第一行第一列中的值。

createDbFromSqlStatements
public static void createDbFromSqlStatements(Context context,
String dbName,
int dbVersion,
String sqlStatements)
Creates a db and populates it with the sql statements in sqlStatements.
参数:
context - the context to use to create the db
dbName - the name of the db to create
dbVersion - the version to set on the db
sqlStatements - the statements to use to populate the db.
This should be a single stringof the form returned by sqlite3’s .dump command (statements separated bysemicolons)

0 0
原创粉丝点击