DatabaseUtils
public
class
DatabaseUtils
extends Object
java.lang.Object | |
↳ | android.database.DatabaseUtils |
Static utility methods for dealing with databases and Cursor
s.
Summary
Nested classes | |
---|---|
class |
DatabaseUtils.InsertHelper
This class was deprecated
in API level 17.
Use |
Constants | |
---|---|
int |
STATEMENT_ABORT
One of the values returned by |
int |
STATEMENT_ATTACH
One of the values returned by |
int |
STATEMENT_BEGIN
One of the values returned by |
int |
STATEMENT_COMMIT
One of the values returned by |
int |
STATEMENT_DDL
One of the values returned by |
int |
STATEMENT_OTHER
One of the values returned by |
int |
STATEMENT_PRAGMA
One of the values returned by |
int |
STATEMENT_SELECT
One of the values returned by |
int |
STATEMENT_UNPREPARED
One of the values returned by |
int |
STATEMENT_UPDATE
One of the values returned by |
Public constructors | |
---|---|
DatabaseUtils()
|
Public methods | |
---|---|
static
void
|
appendEscapedSQLString(StringBuilder sb, String sqlString)
Appends an SQL string to the given StringBuilder, including the opening and closing single quotes. |
static
String[]
|
appendSelectionArgs(String[] originalValues, String[] newValues)
Appends one set of selection args to another. |
static
final
void
|
appendValueToSql(StringBuilder sql, Object value)
Appends an Object to an SQL string with the proper escaping, etc. |
static
void
|
bindObjectToProgram(SQLiteProgram prog, int index, Object value)
Binds the given Object to the given SQLiteProgram using the proper typing. |
static
ParcelFileDescriptor
|
blobFileDescriptorForQuery(SQLiteStatement prog, String[] selectionArgs)
Utility method to run the pre-compiled query and return the blob value in the first column of the first row. |
static
ParcelFileDescriptor
|
blobFileDescriptorForQuery(SQLiteDatabase db, String query, String[] selectionArgs)
Utility method to run the query on the db and return the blob value in the first column of the first row. |
static
String
|
concatenateWhere(String a, String b)
Concatenates two SQL WHERE clauses, handling empty or null values. |
static
void
|
createDbFromSqlStatements(Context context, String dbName, int dbVersion, String sqlStatements)
Creates a db and populates it with the sql statements in sqlStatements. |
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. |
static
void
|
cursorDoubleToContentValuesIfPresent(Cursor cursor, ContentValues values, String column)
Reads a Double out of a column in a Cursor and writes it to a ContentValues. |
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. |
static
void
|
cursorFloatToContentValuesIfPresent(Cursor cursor, ContentValues values, String column)
Reads a Float out of a column in a Cursor and writes it to a ContentValues. |
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. |
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. |
static
void
|
cursorIntToContentValuesIfPresent(Cursor cursor, ContentValues values, String column)
Reads a Integer out of a column in a Cursor and writes it to a ContentValues. |
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. |
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. |
static
void
|
cursorLongToContentValuesIfPresent(Cursor cursor, ContentValues values, String column)
Reads a Long out of a column in a Cursor and writes it to a ContentValues. |
static
void
|
cursorRowToContentValues(Cursor cursor, ContentValues values)
Read the entire contents of a cursor row and store them in a ContentValues. |
static
void
|
cursorShortToContentValuesIfPresent(Cursor cursor, ContentValues values, String column)
Reads a Short out of a column in a Cursor and writes it to a ContentValues. |
static
void
|
cursorStringToContentValues(Cursor cursor, String field, ContentValues values, String key)
Reads a String out of a field in a Cursor and writes it to a Map. |
static
void
|
cursorStringToContentValues(Cursor cursor, String field, ContentValues values)
Reads a String out of a field in a Cursor and writes it to a Map. |
static
void
|
cursorStringToContentValuesIfPresent(Cursor cursor, ContentValues values, String column)
Reads a String out of a column in a Cursor and writes it to a ContentValues. |
static
void
|
cursorStringToInsertHelper(Cursor cursor, String field, DatabaseUtils.InsertHelper inserter, int index)
Reads a String out of a field in a Cursor and writes it to an InsertHelper. |
static
void
|
dumpCurrentRow(Cursor cursor, StringBuilder sb)
Prints the contents of a Cursor's current row to a StringBuilder. |
static
void
|
dumpCurrentRow(Cursor cursor, PrintStream stream)
Prints the contents of a Cursor's current row to a PrintSteam. |
static
void
|
dumpCurrentRow(Cursor cursor)
Prints the contents of a Cursor's current row to System.out. |
static
String
|
dumpCurrentRowToString(Cursor cursor)
Dump the contents of a Cursor's current row to a String. |
static
void
|
dumpCursor(Cursor cursor, PrintStream stream)
Prints the contents of a Cursor to a PrintSteam. |
static
void
|
dumpCursor(Cursor cursor)
Prints the contents of a Cursor to System.out. |
static
void
|
dumpCursor(Cursor cursor, StringBuilder sb)
Prints the contents of a Cursor to a StringBuilder. |
static
String
|
dumpCursorToString(Cursor cursor)
Prints the contents of a Cursor to a String. |
static
String
|
getCollationKey(String name)
return the collation key |
static
String
|
getHexCollationKey(String name)
return the collation key in hex format |
static
int
|
getSqlStatementType(String sql)
Returns one of the following which represent the type of the given SQL statement. |
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. |
static
long
|
longForQuery(SQLiteStatement prog, String[] selectionArgs)
Utility method to run the pre-compiled query and return the value in the first column of the first row. |
static
long
|
queryNumEntries(SQLiteDatabase db, String table, String selection)
Query the table for the number of rows in the table. |
static
long
|
queryNumEntries(SQLiteDatabase db, String table, String selection, String[] selectionArgs)
Query the table for the number of rows in the table. |
static
long
|
queryNumEntries(SQLiteDatabase db, String table)
Query the table for the number of rows in the table. |
static
final
void
|
readExceptionFromParcel(Parcel reply)
Special function for reading an exception result from the header of a parcel, to be used after receiving the result of a transaction. |
static
void
|
readExceptionWithFileNotFoundExceptionFromParcel(Parcel reply)
|
static
void
|
readExceptionWithOperationApplicationExceptionFromParcel(Parcel reply)
|
static
String
|
sqlEscapeString(String value)
SQL-escape a string. |
static
String
|
stringForQuery(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. |
static
String
|
stringForQuery(SQLiteStatement prog, String[] selectionArgs)
Utility method to run the pre-compiled query and return the value in the first column of the first row. |
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. |
Inherited methods | |
---|---|
Constants
STATEMENT_ABORT
public static final int STATEMENT_ABORT
One of the values returned by getSqlStatementType(java.lang.String)
.
Constant Value: 6 (0x00000006)
STATEMENT_ATTACH
public static final int STATEMENT_ATTACH
One of the values returned by getSqlStatementType(java.lang.String)
.
Constant Value: 3 (0x00000003)
STATEMENT_BEGIN
public static final int STATEMENT_BEGIN
One of the values returned by getSqlStatementType(java.lang.String)
.
Constant Value: 4 (0x00000004)
STATEMENT_COMMIT
public static final int STATEMENT_COMMIT
One of the values returned by getSqlStatementType(java.lang.String)
.
Constant Value: 5 (0x00000005)
STATEMENT_DDL
public static final int STATEMENT_DDL
One of the values returned by getSqlStatementType(java.lang.String)
.
Constant Value: 8 (0x00000008)
STATEMENT_OTHER
public static final int STATEMENT_OTHER
One of the values returned by getSqlStatementType(java.lang.String)
.
Constant Value: 99 (0x00000063)
STATEMENT_PRAGMA
public static final int STATEMENT_PRAGMA
One of the values returned by getSqlStatementType(java.lang.String)
.
Constant Value: 7 (0x00000007)
STATEMENT_SELECT
public static final int STATEMENT_SELECT
One of the values returned by getSqlStatementType(java.lang.String)
.
Constant Value: 1 (0x00000001)
STATEMENT_UNPREPARED
public static final int STATEMENT_UNPREPARED
One of the values returned by getSqlStatementType(java.lang.String)
.
Constant Value: 9 (0x00000009)
STATEMENT_UPDATE
public static final int STATEMENT_UPDATE
One of the values returned by getSqlStatementType(java.lang.String)
.
Constant Value: 2 (0x00000002)
Public constructors
DatabaseUtils
public DatabaseUtils ()
Public methods
appendEscapedSQLString
public static void appendEscapedSQLString (StringBuilder sb, String sqlString)
Appends an SQL string to the given StringBuilder, including the opening and closing single quotes. Any single quotes internal to sqlString will be escaped. This method is deprecated because we want to encourage everyone to use the "?" binding form. However, when implementing a ContentProvider, one may want to add WHERE clauses that were not provided by the caller. Since "?" is a positional form, using it in this case could break the caller because the indexes would be shifted to accomodate the ContentProvider's internal bindings. In that case, it may be necessary to construct a WHERE clause manually. This method is useful for those cases.
Parameters | |
---|---|
sb |
StringBuilder : the StringBuilder that the SQL string will be appended to |
sqlString |
String : the raw string to be appended, which may contain single
quotes |
appendSelectionArgs
public static String[] appendSelectionArgs (String[] originalValues, String[] newValues)
Appends one set of selection args to another. This is useful when adding a selection argument to a user provided set.
Parameters | |
---|---|
originalValues |
String |
newValues |
String |
Returns | |
---|---|
String[] |
appendValueToSql
public static final void appendValueToSql (StringBuilder sql, Object value)
Appends an Object to an SQL string with the proper escaping, etc.
Parameters | |
---|---|
sql |
StringBuilder |
value |
Object |
bindObjectToProgram
public static void bindObjectToProgram (SQLiteProgram prog, int index, Object value)
Binds the given Object to the given SQLiteProgram using the proper typing. For example, bind numbers as longs/doubles, and everything else as a string by call toString() on it.
Parameters | |
---|---|
prog |
SQLiteProgram : the program to bind the object to |
index |
int : the 1-based index to bind at |
value |
Object : the value to bind |
blobFileDescriptorForQuery
public static ParcelFileDescriptor blobFileDescriptorForQuery (SQLiteStatement prog, String[] selectionArgs)
Utility method to run the pre-compiled query and return the blob value in the first column of the first row.
Parameters | |
---|---|
prog |
SQLiteStatement |
selectionArgs |
String |
Returns | |
---|---|
ParcelFileDescriptor |
A read-only file descriptor for a copy of the blob value. |
blobFileDescriptorForQuery
public static ParcelFileDescriptor blobFileDescriptorForQuery (SQLiteDatabase db, String query, String[] selectionArgs)
Utility method to run the query on the db and return the blob value in the first column of the first row.
Parameters | |
---|---|
db |
SQLiteDatabase |
query |
String |
selectionArgs |
String |
Returns | |
---|---|
ParcelFileDescriptor |
A read-only file descriptor for a copy of the blob value. |
concatenateWhere
public static String concatenateWhere (String a, String b)
Concatenates two SQL WHERE clauses, handling empty or null values.
Parameters | |
---|---|
a |
String |
b |
String |
Returns | |
---|---|
String |
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.
Parameters | |
---|---|
context |
Context : the context to use to create the db |
dbName |
String : the name of the db to create |
dbVersion |
int : the version to set on the db |
sqlStatements |
String : the statements to use to populate the db. This should be a single string
of the form returned by sqlite3's .dump command (statements separated by
semicolons) |
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.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
field |
String : The REAL field to read |
values |
ContentValues : The ContentValues to put the value into |
key |
String : The key to store the value with in the map |
cursorDoubleToContentValuesIfPresent
public static void cursorDoubleToContentValuesIfPresent (Cursor cursor, ContentValues values, String column)
Reads a Double out of a column in a Cursor and writes it to a ContentValues. Adds nothing to the ContentValues if the column isn't present or if its value is null.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
values |
ContentValues : The ContentValues to put the value into |
column |
String : The column to read |
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.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
field |
String : The REAL field to read |
values |
ContentValues : The ContentValues to put the value into |
cursorFloatToContentValuesIfPresent
public static void cursorFloatToContentValuesIfPresent (Cursor cursor, ContentValues values, String column)
Reads a Float out of a column in a Cursor and writes it to a ContentValues. Adds nothing to the ContentValues if the column isn't present or if its value is null.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
values |
ContentValues : The ContentValues to put the value into |
column |
String : The column to read |
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.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
field |
String : The INTEGER field to read |
values |
ContentValues : The ContentValues to put the value into, with the field as the key |
key |
String : 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.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
field |
String : The INTEGER field to read |
values |
ContentValues : The ContentValues to put the value into, with the field as the key |
cursorIntToContentValuesIfPresent
public static void cursorIntToContentValuesIfPresent (Cursor cursor, ContentValues values, String column)
Reads a Integer out of a column in a Cursor and writes it to a ContentValues. Adds nothing to the ContentValues if the column isn't present or if its value is null.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
values |
ContentValues : The ContentValues to put the value into |
column |
String : The column to read |
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.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
field |
String : The INTEGER field to read |
values |
ContentValues : The ContentValues to put the value into |
key |
String : 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.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
field |
String : The INTEGER field to read |
values |
ContentValues : The ContentValues to put the value into, with the field as the key |
cursorLongToContentValuesIfPresent
public static void cursorLongToContentValuesIfPresent (Cursor cursor, ContentValues values, String column)
Reads a Long out of a column in a Cursor and writes it to a ContentValues. Adds nothing to the ContentValues if the column isn't present or if its value is null.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
values |
ContentValues : The ContentValues to put the value into |
column |
String : The column to read |
cursorRowToContentValues
public static void cursorRowToContentValues (Cursor cursor, ContentValues values)
Read the entire contents of a cursor row and store them in a ContentValues.
Parameters | |
---|---|
cursor |
Cursor : the cursor to read from. |
values |
ContentValues : the ContentValues to put the row into. |
cursorShortToContentValuesIfPresent
public static void cursorShortToContentValuesIfPresent (Cursor cursor, ContentValues values, String column)
Reads a Short out of a column in a Cursor and writes it to a ContentValues. Adds nothing to the ContentValues if the column isn't present or if its value is null.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
values |
ContentValues : The ContentValues to put the value into |
column |
String : The column to read |
cursorStringToContentValues
public static void cursorStringToContentValues (Cursor cursor, String field, ContentValues values, String key)
Reads a String out of a field in a Cursor and writes it to a Map.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
field |
String : The TEXT field to read |
values |
ContentValues : The ContentValues to put the value into, with the field as the key |
key |
String : The key to store the value with in the map |
cursorStringToContentValues
public static void cursorStringToContentValues (Cursor cursor, String field, ContentValues values)
Reads a String out of a field in a Cursor and writes it to a Map.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
field |
String : The TEXT field to read |
values |
ContentValues : The ContentValues to put the value into, with the field as the key |
cursorStringToContentValuesIfPresent
public static void cursorStringToContentValuesIfPresent (Cursor cursor, ContentValues values, String column)
Reads a String out of a column in a Cursor and writes it to a ContentValues. Adds nothing to the ContentValues if the column isn't present or if its value is null.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
values |
ContentValues : The ContentValues to put the value into |
column |
String : The column to read |
cursorStringToInsertHelper
public static void cursorStringToInsertHelper (Cursor cursor, String field, DatabaseUtils.InsertHelper inserter, int index)
Reads a String out of a field in a Cursor and writes it to an InsertHelper.
Parameters | |
---|---|
cursor |
Cursor : The cursor to read from |
field |
String : The TEXT field to read |
inserter |
DatabaseUtils.InsertHelper : The InsertHelper to bind into |
index |
int : the index of the bind entry in the InsertHelper |
dumpCurrentRow
public static void dumpCurrentRow (Cursor cursor, StringBuilder sb)
Prints the contents of a Cursor's current row to a StringBuilder.
Parameters | |
---|---|
cursor |
Cursor : the cursor to print |
sb |
StringBuilder : the StringBuilder to print to |
dumpCurrentRow
public static void dumpCurrentRow (Cursor cursor, PrintStream stream)
Prints the contents of a Cursor's current row to a PrintSteam.
Parameters | |
---|---|
cursor |
Cursor : the cursor to print |
stream |
PrintStream : the stream to print to |
dumpCurrentRow
public static void dumpCurrentRow (Cursor cursor)
Prints the contents of a Cursor's current row to System.out.
Parameters | |
---|---|
cursor |
Cursor : the cursor to print from |
dumpCurrentRowToString
public static String dumpCurrentRowToString (Cursor cursor)
Dump the contents of a Cursor's current row to a String.
Parameters | |
---|---|
cursor |
Cursor : the cursor to print |
Returns | |
---|---|
String |
a String that contains the dumped cursor row |
dumpCursor
public static void dumpCursor (Cursor cursor, PrintStream stream)
Prints the contents of a Cursor to a PrintSteam. The position is restored after printing.
Parameters | |
---|---|
cursor |
Cursor : the cursor to print |
stream |
PrintStream : the stream to print to |
dumpCursor
public static void dumpCursor (Cursor cursor)
Prints the contents of a Cursor to System.out. The position is restored after printing.
Parameters | |
---|---|
cursor |
Cursor : the cursor to print |
dumpCursor
public static void dumpCursor (Cursor cursor, StringBuilder sb)
Prints the contents of a Cursor to a StringBuilder. The position is restored after printing.
Parameters | |
---|---|
cursor |
Cursor : the cursor to print |
sb |
StringBuilder : the StringBuilder to print to |
dumpCursorToString
public static String dumpCursorToString (Cursor cursor)
Prints the contents of a Cursor to a String. The position is restored after printing.
Parameters | |
---|---|
cursor |
Cursor : the cursor to print |
Returns | |
---|---|
String |
a String that contains the dumped cursor |
getCollationKey
public static String getCollationKey (String name)
return the collation key
Returns | |
---|---|
String |
the collation key |
getHexCollationKey
public static String getHexCollationKey (String name)
return the collation key in hex format
Returns | |
---|---|
String |
the collation key in hex format |
getSqlStatementType
public static int getSqlStatementType (String sql)
Returns one of the following which represent the type of the given SQL statement.
STATEMENT_SELECT
STATEMENT_UPDATE
STATEMENT_ATTACH
STATEMENT_BEGIN
STATEMENT_COMMIT
STATEMENT_ABORT
STATEMENT_PRAGMA
STATEMENT_DDL
STATEMENT_UNPREPARED
STATEMENT_OTHER
Parameters | |
---|---|
sql |
String : the SQL statement whose type is returned by this method |
Returns | |
---|---|
int |
one of the values listed above |
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.
Parameters | |
---|---|
db |
SQLiteDatabase |
query |
String |
selectionArgs |
String |
Returns | |
---|---|
long |
longForQuery
public static long longForQuery (SQLiteStatement prog, String[] selectionArgs)
Utility method to run the pre-compiled query and return the value in the first column of the first row.
Parameters | |
---|---|
prog |
SQLiteStatement |
selectionArgs |
String |
Returns | |
---|---|
long |
queryNumEntries
public static long queryNumEntries (SQLiteDatabase db, String table, String selection)
Query the table for the number of rows in the table.
Parameters | |
---|---|
db |
SQLiteDatabase : the database the table is in |
table |
String : the name of the table to query |
selection |
String : A filter declaring which rows to return,
formatted as an SQL WHERE clause (excluding the WHERE itself).
Passing null will count all rows for the given table |
Returns | |
---|---|
long |
the number of rows in the table filtered by the selection |
queryNumEntries
public static long queryNumEntries (SQLiteDatabase db, String table, String selection, String[] selectionArgs)
Query the table for the number of rows in the table.
Parameters | |
---|---|
db |
SQLiteDatabase : the database the table is in |
table |
String : the name of the table to query |
selection |
String : A filter declaring which rows to return,
formatted as an SQL WHERE clause (excluding the WHERE itself).
Passing null will count all rows for the given table |
selectionArgs |
String : You may include ?s in selection,
which will be replaced by the values from selectionArgs,
in order that they appear in the selection.
The values will be bound as Strings. |
Returns | |
---|---|
long |
the number of rows in the table filtered by the selection |
queryNumEntries
public static long queryNumEntries (SQLiteDatabase db, String table)
Query the table for the number of rows in the table.
Parameters | |
---|---|
db |
SQLiteDatabase : the database the table is in |
table |
String : the name of the table to query |
Returns | |
---|---|
long |
the number of rows in the table |
readExceptionFromParcel
public static final void readExceptionFromParcel (Parcel reply)
Special function for reading an exception result from the header of a parcel, to be used after receiving the result of a transaction. This will throw the exception for you if it had been written to the Parcel, otherwise return and let you read the normal result data from the Parcel.
Parameters | |
---|---|
reply |
Parcel : Parcel to read from |
readExceptionWithFileNotFoundExceptionFromParcel
public static void readExceptionWithFileNotFoundExceptionFromParcel (Parcel reply)
Parameters | |
---|---|
reply |
Parcel |
Throws | |
---|---|
FileNotFoundException |
readExceptionWithOperationApplicationExceptionFromParcel
public static void readExceptionWithOperationApplicationExceptionFromParcel (Parcel reply)
Parameters | |
---|---|
reply |
Parcel |
Throws | |
---|---|
OperationApplicationException |
sqlEscapeString
public static String sqlEscapeString (String value)
SQL-escape a string.
Parameters | |
---|---|
value |
String |
Returns | |
---|---|
String |
stringForQuery
public static String stringForQuery (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.
Parameters | |
---|---|
db |
SQLiteDatabase |
query |
String |
selectionArgs |
String |
Returns | |
---|---|
String |
stringForQuery
public static String stringForQuery (SQLiteStatement prog, String[] selectionArgs)
Utility method to run the pre-compiled query and return the value in the first column of the first row.
Parameters | |
---|---|
prog |
SQLiteStatement |
selectionArgs |
String |
Returns | |
---|---|
String |
writeExceptionToParcel
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
Parameters | |
---|---|
reply |
Parcel : Parcel to write to |
e |
Exception : The Exception to be written. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-04 UTC.