Google is committed to advancing racial equity for Black communities. See how.
Added in API level 1
Deprecated in API level 17

InsertHelper

open class InsertHelper
kotlin.Any
   ↳ android.database.DatabaseUtils.InsertHelper

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

This class is not thread-safe.

Summary

Public constructors

<init>(db: SQLiteDatabase!, tableName: String!)

Public methods

open Unit
bind(index: Int, value: Double)

Bind the value to an index.

open Unit
bind(index: Int, value: Float)

Bind the value to an index.

open Unit
bind(index: Int, value: Long)

Bind the value to an index.

open Unit
bind(index: Int, value: Int)

Bind the value to an index.

open Unit
bind(index: Int, value: Boolean)

Bind the value to an index.

open Unit
bind(index: Int, value: ByteArray!)

Bind the value to an index.

open Unit
bind(index: Int, value: String!)

Bind the value to an index.

open Unit
bindNull(index: Int)

Bind null to an index.

open Unit

Close this object and release any resources associated with it.

open Long

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

open Int

Returns the index of the specified column.

open Long

Performs an insert, adding a new row with the given values.

open Unit

Prepare the InsertHelper for an insert.

open Unit

Prepare the InsertHelper for a replace.

open Long

Performs an insert, adding a new row with the given values.

Public constructors

<init>

Added in API level 1
InsertHelper(
    db: SQLiteDatabase!,
    tableName: String!)
Parameters
db SQLiteDatabase!: the SQLiteDatabase to insert into
tableName String!: the name of the table to insert into

Public methods

bind

Added in API level 1
Deprecated in API level 17
open fun bind(
    index: Int,
    value: Double
): Unit

Deprecated.

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

Parameters
index Int: the index of the slot to which to bind
value Double: the value to bind

bind

Added in API level 1
Deprecated in API level 17
open fun bind(
    index: Int,
    value: Float
): Unit

Deprecated.

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

Parameters
index Int: the index of the slot to which to bind
value Float: the value to bind

bind

Added in API level 1
Deprecated in API level 17
open fun bind(
    index: Int,
    value: Long
): Unit

Deprecated.

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

Parameters
index Int: the index of the slot to which to bind
value Long: the value to bind

bind

Added in API level 1
Deprecated in API level 17
open fun bind(
    index: Int,
    value: Int
): Unit

Deprecated.

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

Parameters
index Int: the index of the slot to which to bind
value Int: the value to bind

bind

Added in API level 1
Deprecated in API level 17
open fun bind(
    index: Int,
    value: Boolean
): Unit

Deprecated.

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

Parameters
index Int: the index of the slot to which to bind
value Boolean: the value to bind

bind

Added in API level 1
Deprecated in API level 17
open fun bind(
    index: Int,
    value: ByteArray!
): Unit

Deprecated.

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

Parameters
index Int: the index of the slot to which to bind
value ByteArray!: the value to bind

bind

Added in API level 1
Deprecated in API level 17
open fun bind(
    index: Int,
    value: String!
): Unit

Deprecated.

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

Parameters
index Int: the index of the slot to which to bind
value String!: the value to bind

bindNull

Added in API level 1
Deprecated in API level 17
open fun bindNull(index: Int): Unit

Deprecated.

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

Parameters
index Int: the index of the slot to which to bind

close

Added in API level 1
Deprecated in API level 17
open fun close(): Unit

Deprecated.

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

execute

Added in API level 1
Deprecated in API level 17
open fun execute(): Long

Deprecated.

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().

Return
Long the row ID of the newly inserted row, or -1 if an error occurred

getColumnIndex

Added in API level 1
Deprecated in API level 17
open fun getColumnIndex(key: String!): Int

Deprecated.

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

Parameters
key String!: the column name
Return
Int the index of the column

insert

Added in API level 1
Deprecated in API level 17
open fun insert(values: ContentValues!): Long

Deprecated.

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

Parameters
values ContentValues!: the set of values with which to populate the new row
Return
Long the row ID of the newly inserted row, or -1 if an error occurred

prepareForInsert

Added in API level 1
Deprecated in API level 17
open fun prepareForInsert(): Unit

Deprecated.

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

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

prepareForReplace

Added in API level 1
Deprecated in API level 17
open fun prepareForReplace(): Unit

Deprecated.

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

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

replace

Added in API level 1
Deprecated in API level 17
open fun replace(values: ContentValues!): Long

Deprecated.

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.

Parameters
values ContentValues!: the set of values with which to populate the new row
Return
Long the row ID of the newly inserted row, or -1 if an error occurred