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

# DatabaseUtils.InsertHelper

*** ** * ** ***

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

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

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 17.**   

Use `https://developer.android.com/reference/android/database/sqlite/SQLiteStatement` instead.

This class allows users to do multiple inserts into a table using the same statement.

This class is not thread-safe.

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#InsertHelper(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 tableName) ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#bind(int,%20float)(int index, float value) ` Bind the value to an index. |
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#bind(int,%20double)(int index, double value) ` Bind the value to an index. |
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#bind(int,%20int)(int index, int value) ` Bind the value to an index. |
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#bind(int,%20java.lang.String)(int index, https://developer.android.com/reference/java/lang/String value) ` Bind the value to an index. |
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#bind(int,%20long)(int index, long value) ` Bind the value to an index. |
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#bind(int,%20byte[])(int index, byte[] value) ` Bind the value to an index. |
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#bind(int,%20boolean)(int index, boolean value) ` Bind the value to an index. |
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#bindNull(int)(int index) ` Bind null to an index. |
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#close()() ` Close this object and release any resources associated with it. |
| ` long` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#execute()() ` Execute the previously prepared insert or replace using the bound values since the last call to prepareForInsert or prepareForReplace. |
| ` int` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#getColumnIndex(java.lang.String)(https://developer.android.com/reference/java/lang/String key) ` Returns the index of the specified column. |
| ` long` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#insert(android.content.ContentValues)(https://developer.android.com/reference/android/content/ContentValues values) ` Performs an insert, adding a new row with the given values. |
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#prepareForInsert()() ` Prepare the InsertHelper for an insert. |
| ` void` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#prepareForReplace()() ` Prepare the InsertHelper for a replace. |
| ` long` | ` https://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper#replace(android.content.ContentValues)(https://developer.android.com/reference/android/content/ContentValues values) ` Performs an insert, adding a new row with the given values. |

### 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*.

## Public constructors

### InsertHelper

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

```
public InsertHelper (SQLiteDatabase db, 
                String tableName)
```

<br />

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase`: the SQLiteDatabase to insert into <br /> |
| `tableName` | `String`: the name of the table to insert into <br /> |

## Public methods

### bind

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

```
public void bind (int index, 
                float value)
```

Bind the value to an index. A prepareForInsert() or prepareForReplace() without a matching execute() must have already have been called.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index of the slot to which to bind <br /> |
| `value` | `float`: the value to bind <br /> |

### bind

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

```
public void bind (int index, 
                double value)
```

Bind the value to an index. A prepareForInsert() or prepareForReplace() without a matching execute() must have already have been called.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index of the slot to which to bind <br /> |
| `value` | `double`: the value to bind <br /> |

### bind

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

```
public void bind (int index, 
                int value)
```

Bind the value to an index. A prepareForInsert() or prepareForReplace() without a matching execute() must have already have been called.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index of the slot to which to bind <br /> |
| `value` | `int`: the value to bind <br /> |

### bind

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

```
public void bind (int index, 
                String value)
```

Bind the value to an index. A prepareForInsert() or prepareForReplace() without a matching execute() must have already have been called.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index of the slot to which to bind <br /> |
| `value` | `String`: the value to bind <br /> |

### bind

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

```
public void bind (int index, 
                long value)
```

Bind the value to an index. A prepareForInsert() or prepareForReplace() without a matching execute() must have already have been called.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index of the slot to which to bind <br /> |
| `value` | `long`: the value to bind <br /> |

### bind

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

```
public void bind (int index, 
                byte[] value)
```

Bind the value to an index. A prepareForInsert() or prepareForReplace() without a matching execute() must have already have been called.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index of the slot to which to bind <br /> |
| `value` | `byte`: the value to bind <br /> |

### bind

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

```
public void bind (int index, 
                boolean value)
```

Bind the value to an index. A prepareForInsert() or prepareForReplace() without a matching execute() must have already have been called.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index of the slot to which to bind <br /> |
| `value` | `boolean`: the value to bind <br /> |

### bindNull

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

```
public void bindNull (int index)
```

Bind null to an index. A prepareForInsert() or prepareForReplace() without a matching execute() must have already have been called.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index of the slot to which to bind <br /> |

### close

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

```
public void close ()
```

Close this object and release any resources associated with it. The behavior of calling `insert()` after calling this method is undefined.

<br />

### execute

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

```
public long execute ()
```

Execute the previously prepared insert or replace using the bound values since the last call to prepareForInsert or prepareForReplace.

Note that calling bind() and then execute() is not thread-safe. The only thread-safe way to use this class is to call insert() or replace().

<br />

| Returns ||
|---|---|
| `long` | the row ID of the newly inserted row, or -1 if an error occurred <br /> |

### getColumnIndex

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

```
public int getColumnIndex (String key)
```

Returns the index of the specified column. This is index is suitagble for use in calls to bind().

<br />

| Parameters ||
|---|---|
| `key` | `String`: the column name <br /> |

| Returns ||
|---|---|
| `int` | the index of the column <br /> |

### insert

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

```
public long insert (ContentValues values)
```

Performs an insert, adding a new row with the given values. If the table contains conflicting rows, an error is returned.

<br />

| Parameters ||
|---|---|
| `values` | `ContentValues`: the set of values with which to populate the new row <br /> |

| Returns ||
|---|---|
| `long` | the row ID of the newly inserted row, or -1 if an error occurred <br /> |

### prepareForInsert

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

```
public void prepareForInsert ()
```

Prepare the InsertHelper for an insert. The pattern for this is:

- prepareForInsert()
- bind(index, value);
- bind(index, value);
- ...
- bind(index, value);
- execute();

<br />

<br />

### prepareForReplace

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

```
public void prepareForReplace ()
```

Prepare the InsertHelper for a replace. The pattern for this is:

- prepareForReplace()
- bind(index, value);
- bind(index, value);
- ...
- bind(index, value);
- execute();

<br />

<br />

### replace

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

```
public long replace (ContentValues values)
```

Performs an insert, adding a new row with the given values. If the table contains conflicting rows, they are deleted and replaced with the new row.

<br />

| Parameters ||
|---|---|
| `values` | `ContentValues`: the set of values with which to populate the new row <br /> |

| Returns ||
|---|---|
| `long` | the row ID of the newly inserted row, or -1 if an error occurred <br /> |