Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/database/DatabaseUtils#nestedclasses) \| [Constants](https://developer.android.com/reference/android/database/DatabaseUtils#constants) \| [Ctors](https://developer.android.com/reference/android/database/DatabaseUtils#pubctors) \| [Methods](https://developer.android.com/reference/android/database/DatabaseUtils#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/database/DatabaseUtils#inhmethods)

# DatabaseUtils

*** ** * ** ***

` public class DatabaseUtils `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.database.DatabaseUtils |

<br />

*** ** * ** ***

Static utility methods for dealing with databases and `https://developer.android.com/reference/android/database/Cursor`s.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper` *This class was deprecated in API level 17. Use `https://developer.android.com/reference/android/database/sqlite/SQLiteStatement` instead.* |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_ABORT` One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`. |
| `int` | `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_ATTACH` One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`. |
| `int` | `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_BEGIN` One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`. |
| `int` | `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_COMMIT` One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`. |
| `int` | `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_DDL` One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`. |
| `int` | `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_OTHER` One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`. |
| `int` | `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_PRAGMA` One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`. |
| `int` | `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_SELECT` One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`. |
| `int` | `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_UNPREPARED` One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`. |
| `int` | `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_UPDATE` One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/database/DatabaseUtils#DatabaseUtils()() ` |

| ### Public methods ||
|---|---|
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#appendEscapedSQLString(java.lang.StringBuilder,%20java.lang.String)(https://developer.android.com/reference/java/lang/StringBuilder sb, https://developer.android.com/reference/java/lang/String sqlString) ` Appends an SQL string to the given StringBuilder, including the opening and closing single quotes. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/DatabaseUtils#appendSelectionArgs(java.lang.String[],%20java.lang.String[])(https://developer.android.com/reference/java/lang/String originalValues, https://developer.android.com/reference/java/lang/String newValues) ` Appends one set of selection args to another. |
| ` static final void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#appendValueToSql(java.lang.StringBuilder,%20java.lang.Object)(https://developer.android.com/reference/java/lang/StringBuilder sql, https://developer.android.com/reference/java/lang/Object value) ` Appends an Object to an SQL string with the proper escaping, etc. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#bindObjectToProgram(android.database.sqlite.SQLiteProgram,%20int,%20java.lang.Object)(https://developer.android.com/reference/android/database/sqlite/SQLiteProgram prog, int index, https://developer.android.com/reference/java/lang/Object value) ` Binds the given Object to the given SQLiteProgram using the proper typing. |
| ` static https://developer.android.com/reference/android/os/ParcelFileDescriptor` | ` https://developer.android.com/reference/android/database/DatabaseUtils#blobFileDescriptorForQuery(android.database.sqlite.SQLiteStatement,%20java.lang.String[])(https://developer.android.com/reference/android/database/sqlite/SQLiteStatement prog, https://developer.android.com/reference/java/lang/String selectionArgs) ` Utility method to run the pre-compiled query and return the blob value in the first column of the first row. |
| ` static https://developer.android.com/reference/android/os/ParcelFileDescriptor` | ` https://developer.android.com/reference/android/database/DatabaseUtils#blobFileDescriptorForQuery(android.database.sqlite.SQLiteDatabase,%20java.lang.String,%20java.lang.String[])(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/java/lang/String query, https://developer.android.com/reference/java/lang/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 https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/DatabaseUtils#concatenateWhere(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String a, https://developer.android.com/reference/java/lang/String b) ` Concatenates two SQL WHERE clauses, handling empty or null values. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#createDbFromSqlStatements(android.content.Context,%20java.lang.String,%20int,%20java.lang.String)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/java/lang/String dbName, int dbVersion, https://developer.android.com/reference/java/lang/String sqlStatements) ` Creates a db and populates it with the sql statements in sqlStatements. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorDoubleToContentValues(android.database.Cursor,%20java.lang.String,%20android.content.ContentValues,%20java.lang.String)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/String field, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String key) ` Reads a Double out of a field in a Cursor and writes it to a Map. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorDoubleToContentValuesIfPresent(android.database.Cursor,%20android.content.ContentValues,%20java.lang.String)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String column) ` Reads a Double out of a column in a Cursor and writes it to a ContentValues. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorDoubleToCursorValues(android.database.Cursor,%20java.lang.String,%20android.content.ContentValues)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/String field, https://developer.android.com/reference/android/content/ContentValues values) ` Reads a Double out of a field in a Cursor and writes it to a Map. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorFloatToContentValuesIfPresent(android.database.Cursor,%20android.content.ContentValues,%20java.lang.String)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String column) ` Reads a Float out of a column in a Cursor and writes it to a ContentValues. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorIntToContentValues(android.database.Cursor,%20java.lang.String,%20android.content.ContentValues,%20java.lang.String)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/String field, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String key) ` Reads a Integer out of a field in a Cursor and writes it to a Map. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorIntToContentValues(android.database.Cursor,%20java.lang.String,%20android.content.ContentValues)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/String field, https://developer.android.com/reference/android/content/ContentValues values) ` Reads an Integer out of a field in a Cursor and writes it to a Map. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorIntToContentValuesIfPresent(android.database.Cursor,%20android.content.ContentValues,%20java.lang.String)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String column) ` Reads a Integer out of a column in a Cursor and writes it to a ContentValues. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorLongToContentValues(android.database.Cursor,%20java.lang.String,%20android.content.ContentValues,%20java.lang.String)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/String field, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String key) ` Reads a Long out of a field in a Cursor and writes it to a Map. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorLongToContentValues(android.database.Cursor,%20java.lang.String,%20android.content.ContentValues)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/String field, https://developer.android.com/reference/android/content/ContentValues values) ` Reads a Long out of a field in a Cursor and writes it to a Map. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorLongToContentValuesIfPresent(android.database.Cursor,%20android.content.ContentValues,%20java.lang.String)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String column) ` Reads a Long out of a column in a Cursor and writes it to a ContentValues. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorRowToContentValues(android.database.Cursor,%20android.content.ContentValues)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/android/content/ContentValues values) ` Read the entire contents of a cursor row and store them in a ContentValues. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorShortToContentValuesIfPresent(android.database.Cursor,%20android.content.ContentValues,%20java.lang.String)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String column) ` Reads a Short out of a column in a Cursor and writes it to a ContentValues. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorStringToContentValues(android.database.Cursor,%20java.lang.String,%20android.content.ContentValues,%20java.lang.String)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/String field, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String key) ` Reads a String out of a field in a Cursor and writes it to a Map. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorStringToContentValues(android.database.Cursor,%20java.lang.String,%20android.content.ContentValues)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/String field, https://developer.android.com/reference/android/content/ContentValues values) ` Reads a String out of a field in a Cursor and writes it to a Map. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorStringToContentValuesIfPresent(android.database.Cursor,%20android.content.ContentValues,%20java.lang.String)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String column) ` Reads a String out of a column in a Cursor and writes it to a ContentValues. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#cursorStringToInsertHelper(android.database.Cursor,%20java.lang.String,%20android.database.DatabaseUtils.InsertHelper,%20int)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/String field, https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper inserter, int index) ` Reads a String out of a field in a Cursor and writes it to an InsertHelper. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#dumpCurrentRow(android.database.Cursor,%20java.lang.StringBuilder)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/StringBuilder sb) ` Prints the contents of a Cursor's current row to a StringBuilder. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#dumpCurrentRow(android.database.Cursor,%20java.io.PrintStream)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/io/PrintStream stream) ` Prints the contents of a Cursor's current row to a PrintSteam. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#dumpCurrentRow(android.database.Cursor)(https://developer.android.com/reference/android/database/Cursor cursor) ` Prints the contents of a Cursor's current row to System.out. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/DatabaseUtils#dumpCurrentRowToString(android.database.Cursor)(https://developer.android.com/reference/android/database/Cursor cursor) ` Dump the contents of a Cursor's current row to a String. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#dumpCursor(android.database.Cursor,%20java.io.PrintStream)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/io/PrintStream stream) ` Prints the contents of a Cursor to a PrintSteam. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#dumpCursor(android.database.Cursor)(https://developer.android.com/reference/android/database/Cursor cursor) ` Prints the contents of a Cursor to System.out. |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#dumpCursor(android.database.Cursor,%20java.lang.StringBuilder)(https://developer.android.com/reference/android/database/Cursor cursor, https://developer.android.com/reference/java/lang/StringBuilder sb) ` Prints the contents of a Cursor to a StringBuilder. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/DatabaseUtils#dumpCursorToString(android.database.Cursor)(https://developer.android.com/reference/android/database/Cursor cursor) ` Prints the contents of a Cursor to a String. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/DatabaseUtils#getCollationKey(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` return the collation key |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/DatabaseUtils#getHexCollationKey(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` return the collation key in hex format |
| ` static int` | ` https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)(https://developer.android.com/reference/java/lang/String sql) ` Returns one of the following which represent the type of the given SQL statement. |
| ` static long` | ` https://developer.android.com/reference/android/database/DatabaseUtils#longForQuery(android.database.sqlite.SQLiteDatabase,%20java.lang.String,%20java.lang.String[])(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/java/lang/String query, https://developer.android.com/reference/java/lang/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` | ` https://developer.android.com/reference/android/database/DatabaseUtils#longForQuery(android.database.sqlite.SQLiteStatement,%20java.lang.String[])(https://developer.android.com/reference/android/database/sqlite/SQLiteStatement prog, https://developer.android.com/reference/java/lang/String selectionArgs) ` Utility method to run the pre-compiled query and return the value in the first column of the first row. |
| ` static long` | ` https://developer.android.com/reference/android/database/DatabaseUtils#queryNumEntries(android.database.sqlite.SQLiteDatabase,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/java/lang/String table, https://developer.android.com/reference/java/lang/String selection) ` Query the table for the number of rows in the table. |
| ` static long` | ` https://developer.android.com/reference/android/database/DatabaseUtils#queryNumEntries(android.database.sqlite.SQLiteDatabase,%20java.lang.String,%20java.lang.String,%20java.lang.String[])(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/java/lang/String table, https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String selectionArgs) ` Query the table for the number of rows in the table. |
| ` static long` | ` https://developer.android.com/reference/android/database/DatabaseUtils#queryNumEntries(android.database.sqlite.SQLiteDatabase,%20java.lang.String)(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/java/lang/String table) ` Query the table for the number of rows in the table. |
| ` static final void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#readExceptionFromParcel(android.os.Parcel)(https://developer.android.com/reference/android/os/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` | ` https://developer.android.com/reference/android/database/DatabaseUtils#readExceptionWithFileNotFoundExceptionFromParcel(android.os.Parcel)(https://developer.android.com/reference/android/os/Parcel reply) ` |
| ` static void` | ` https://developer.android.com/reference/android/database/DatabaseUtils#readExceptionWithOperationApplicationExceptionFromParcel(android.os.Parcel)(https://developer.android.com/reference/android/os/Parcel reply) ` |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/DatabaseUtils#sqlEscapeString(java.lang.String)(https://developer.android.com/reference/java/lang/String value) ` SQL-escape a string. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/DatabaseUtils#stringForQuery(android.database.sqlite.SQLiteDatabase,%20java.lang.String,%20java.lang.String[])(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/java/lang/String query, https://developer.android.com/reference/java/lang/String selectionArgs) ` Utility method to run the query on the db and return the value in the first column of the first row. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/DatabaseUtils#stringForQuery(android.database.sqlite.SQLiteStatement,%20java.lang.String[])(https://developer.android.com/reference/android/database/sqlite/SQLiteStatement prog, https://developer.android.com/reference/java/lang/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` | ` https://developer.android.com/reference/android/database/DatabaseUtils#writeExceptionToParcel(android.os.Parcel,%20java.lang.Exception)(https://developer.android.com/reference/android/os/Parcel reply, https://developer.android.com/reference/java/lang/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

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### STATEMENT_ABORT

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATEMENT_ABORT
```

One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`.

<br />

Constant Value: 6 (0x00000006)

### STATEMENT_ATTACH

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATEMENT_ATTACH
```

One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`.

<br />

Constant Value: 3 (0x00000003)

### STATEMENT_BEGIN

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATEMENT_BEGIN
```

One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`.

<br />

Constant Value: 4 (0x00000004)

### STATEMENT_COMMIT

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATEMENT_COMMIT
```

One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`.

<br />

Constant Value: 5 (0x00000005)

### STATEMENT_DDL

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATEMENT_DDL
```

One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`.

<br />

Constant Value: 8 (0x00000008)

### STATEMENT_OTHER

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATEMENT_OTHER
```

One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`.

<br />

Constant Value: 99 (0x00000063)

### STATEMENT_PRAGMA

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATEMENT_PRAGMA
```

One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`.

<br />

Constant Value: 7 (0x00000007)

### STATEMENT_SELECT

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATEMENT_SELECT
```

One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`.

<br />

Constant Value: 1 (0x00000001)

### STATEMENT_UNPREPARED

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATEMENT_UNPREPARED
```

One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`.

<br />

Constant Value: 9 (0x00000009)

### STATEMENT_UPDATE

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATEMENT_UPDATE
```

One of the values returned by `https://developer.android.com/reference/android/database/DatabaseUtils#getSqlStatementType(java.lang.String)`.

<br />

Constant Value: 2 (0x00000002)

## Public constructors

### DatabaseUtils

```
public DatabaseUtils ()
```

<br />

<br />

## Public methods

### appendEscapedSQLString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `sb` | `StringBuilder`: the StringBuilder that the SQL string will be appended to <br /> |
| `sqlString` | `String`: the raw string to be appended, which may contain single quotes <br /> |

### appendSelectionArgs

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `originalValues` | `String` <br /> |
| `newValues` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### appendValueToSql

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Appends an Object to an SQL string with the proper escaping, etc.

<br />

| Parameters ||
|---|---|
| `sql` | `StringBuilder` <br /> |
| `value` | `Object` <br /> |

### bindObjectToProgram

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `prog` | `SQLiteProgram`: the program to bind the object to <br /> |
| `index` | `int`: the 1-based index to bind at <br /> |
| `value` | `Object`: the value to bind <br /> |

### blobFileDescriptorForQuery

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `prog` | `SQLiteStatement` <br /> |
| `selectionArgs` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/ParcelFileDescriptor` | A read-only file descriptor for a copy of the blob value. <br /> |

### blobFileDescriptorForQuery

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase` <br /> |
| `query` | `String` <br /> |
| `selectionArgs` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/ParcelFileDescriptor` | A read-only file descriptor for a copy of the blob value. <br /> |

### concatenateWhere

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String concatenateWhere (String a, 
                String b)
```

Concatenates two SQL WHERE clauses, handling empty or null values.

<br />

| Parameters ||
|---|---|
| `a` | `String` <br /> |
| `b` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### createDbFromSqlStatements

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void createDbFromSqlStatements (Context context, 
                String dbName, 
                int dbVersion, 
                String sqlStatements)
```

Creates a db and populates it with the sql statements in sqlStatements.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: the context to use to create the db <br /> |
| `dbName` | `String`: the name of the db to create <br /> |
| `dbVersion` | `int`: the version to set on the db <br /> |
| `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) <br /> |

### cursorDoubleToContentValues

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `field` | `String`: The REAL field to read <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into <br /> |
| `key` | `String`: The key to store the value with in the map <br /> |

### cursorDoubleToContentValuesIfPresent

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into <br /> |
| `column` | `String`: The column to read <br /> |

### cursorDoubleToCursorValues

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `field` | `String`: The REAL field to read <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into <br /> |

### cursorFloatToContentValuesIfPresent

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into <br /> |
| `column` | `String`: The column to read <br /> |

### cursorIntToContentValues

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `field` | `String`: The INTEGER field to read <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into, with the field as the key <br /> |
| `key` | `String`: The key to store the value with in the map <br /> |

### cursorIntToContentValues

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `field` | `String`: The INTEGER field to read <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into, with the field as the key <br /> |

### cursorIntToContentValuesIfPresent

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into <br /> |
| `column` | `String`: The column to read <br /> |

### cursorLongToContentValues

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `field` | `String`: The INTEGER field to read <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into <br /> |
| `key` | `String`: The key to store the value with in the map <br /> |

### cursorLongToContentValues

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `field` | `String`: The INTEGER field to read <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into, with the field as the key <br /> |

### cursorLongToContentValuesIfPresent

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into <br /> |
| `column` | `String`: The column to read <br /> |

### cursorRowToContentValues

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void cursorRowToContentValues (Cursor cursor, 
                ContentValues values)
```

Read the entire contents of a cursor row and store them in a ContentValues.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: the cursor to read from. <br /> |
| `values` | `ContentValues`: the `https://developer.android.com/reference/android/content/ContentValues` to put the row into. <br /> |

### cursorShortToContentValuesIfPresent

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into <br /> |
| `column` | `String`: The column to read <br /> |

### cursorStringToContentValues

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `field` | `String`: The TEXT field to read <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into, with the field as the key <br /> |
| `key` | `String`: The key to store the value with in the map <br /> |

### cursorStringToContentValues

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `field` | `String`: The TEXT field to read <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into, with the field as the key <br /> |

### cursorStringToContentValuesIfPresent

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `values` | `ContentValues`: The `https://developer.android.com/reference/android/content/ContentValues` to put the value into <br /> |
| `column` | `String`: The column to read <br /> |

### cursorStringToInsertHelper

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: The cursor to read from <br /> |
| `field` | `String`: The TEXT field to read <br /> |
| `inserter` | `DatabaseUtils.InsertHelper`: The InsertHelper to bind into <br /> |
| `index` | `int`: the index of the bind entry in the InsertHelper <br /> |

### dumpCurrentRow

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void dumpCurrentRow (Cursor cursor, 
                StringBuilder sb)
```

Prints the contents of a Cursor's current row to a StringBuilder.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: the cursor to print <br /> |
| `sb` | `StringBuilder`: the StringBuilder to print to <br /> |

### dumpCurrentRow

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void dumpCurrentRow (Cursor cursor, 
                PrintStream stream)
```

Prints the contents of a Cursor's current row to a PrintSteam.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: the cursor to print <br /> |
| `stream` | `PrintStream`: the stream to print to <br /> |

### dumpCurrentRow

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void dumpCurrentRow (Cursor cursor)
```

Prints the contents of a Cursor's current row to System.out.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: the cursor to print from <br /> |

### dumpCurrentRowToString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String dumpCurrentRowToString (Cursor cursor)
```

Dump the contents of a Cursor's current row to a String.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: the cursor to print <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a String that contains the dumped cursor row <br /> |

### dumpCursor

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void dumpCursor (Cursor cursor, 
                PrintStream stream)
```

Prints the contents of a Cursor to a PrintSteam. The position is restored after printing.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: the cursor to print <br /> |
| `stream` | `PrintStream`: the stream to print to <br /> |

### dumpCursor

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void dumpCursor (Cursor cursor)
```

Prints the contents of a Cursor to System.out. The position is restored after printing.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: the cursor to print <br /> |

### dumpCursor

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void dumpCursor (Cursor cursor, 
                StringBuilder sb)
```

Prints the contents of a Cursor to a StringBuilder. The position is restored after printing.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: the cursor to print <br /> |
| `sb` | `StringBuilder`: the StringBuilder to print to <br /> |

### dumpCursorToString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String dumpCursorToString (Cursor cursor)
```

Prints the contents of a Cursor to a String. The position is restored after printing.

<br />

| Parameters ||
|---|---|
| `cursor` | `Cursor`: the cursor to print <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a String that contains the dumped cursor <br /> |

### getCollationKey

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String getCollationKey (String name)
```

return the collation key

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the collation key <br /> |

### getHexCollationKey

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String getHexCollationKey (String name)
```

return the collation key in hex format

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the collation key in hex format <br /> |

### getSqlStatementType

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getSqlStatementType (String sql)
```

Returns one of the following which represent the type of the given SQL statement.

1. `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_SELECT`
2. `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_UPDATE`
3. `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_ATTACH`
4. `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_BEGIN`
5. `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_COMMIT`
6. `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_ABORT`
7. `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_PRAGMA`
8. `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_DDL`
9. `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_UNPREPARED`
10. `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_OTHER`

<br />

<br />

| Parameters ||
|---|---|
| `sql` | `String`: the SQL statement whose type is returned by this method <br /> |

| Returns ||
|---|---|
| `int` | one of the values listed above. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_SELECT` - `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_UPDATE` - `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_ATTACH` - `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_BEGIN` - `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_COMMIT` - `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_ABORT` - `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_PRAGMA` - `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_DDL` - `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_UNPREPARED` - `https://developer.android.com/reference/android/database/DatabaseUtils#STATEMENT_OTHER` |

### longForQuery

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase` <br /> |
| `query` | `String` <br /> |
| `selectionArgs` | `String` <br /> |

| Returns ||
|---|---|
| `long` | <br /> |

### longForQuery

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `prog` | `SQLiteStatement` <br /> |
| `selectionArgs` | `String` <br /> |

| Returns ||
|---|---|
| `long` | <br /> |

### queryNumEntries

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static long queryNumEntries (SQLiteDatabase db, 
                String table, 
                String selection)
```

Query the table for the number of rows in the table.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase`: the database the table is in <br /> |
| `table` | `String`: the name of the table to query <br /> |
| `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 <br /> |

| Returns ||
|---|---|
| `long` | the number of rows in the table filtered by the selection <br /> |

### queryNumEntries

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static long queryNumEntries (SQLiteDatabase db, 
                String table, 
                String selection, 
                String[] selectionArgs)
```

Query the table for the number of rows in the table.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase`: the database the table is in <br /> |
| `table` | `String`: the name of the table to query <br /> |
| `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 <br /> |
| `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. <br /> |

| Returns ||
|---|---|
| `long` | the number of rows in the table filtered by the selection <br /> |

### queryNumEntries

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static long queryNumEntries (SQLiteDatabase db, 
                String table)
```

Query the table for the number of rows in the table.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase`: the database the table is in <br /> |
| `table` | `String`: the name of the table to query <br /> |

| Returns ||
|---|---|
| `long` | the number of rows in the table <br /> |

### readExceptionFromParcel

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `reply` | `Parcel`: Parcel to read from <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/Parcel#writeNoException()`
- `https://developer.android.com/reference/android/os/Parcel#readException()`

### readExceptionWithFileNotFoundExceptionFromParcel

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void readExceptionWithFileNotFoundExceptionFromParcel (Parcel reply)
```

<br />

<br />

| Parameters ||
|---|---|
| `reply` | `Parcel` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException` |   |

### readExceptionWithOperationApplicationExceptionFromParcel

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void readExceptionWithOperationApplicationExceptionFromParcel (Parcel reply)
```

<br />

<br />

| Parameters ||
|---|---|
| `reply` | `Parcel` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/content/OperationApplicationException` |   |

### sqlEscapeString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String sqlEscapeString (String value)
```

SQL-escape a string.

<br />

| Parameters ||
|---|---|
| `value` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### stringForQuery

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase` <br /> |
| `query` | `String` <br /> |
| `selectionArgs` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### stringForQuery

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `prog` | `SQLiteStatement` <br /> |
| `selectionArgs` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### writeExceptionToParcel

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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

<br />

| Parameters ||
|---|---|
| `reply` | `Parcel`: Parcel to write to <br /> |
| `e` | `Exception`: The Exception to be written. <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/Parcel#writeNoException()`
- `https://developer.android.com/reference/android/os/Parcel#writeException(java.lang.Exception)`