public static class DatabaseUtils.InsertHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
TABLE_INFO_PRAGMA_COLUMNNAME_INDEX
These are the columns returned by sqlite's "PRAGMA
table_info(...)" command that we depend on.
|
static int |
TABLE_INFO_PRAGMA_DEFAULT_INDEX |
Constructor and Description |
---|
DatabaseUtils.InsertHelper(SQLiteDatabase db,
java.lang.String tableName) |
Modifier and Type | Method and Description |
---|---|
void |
bind(int index,
boolean value)
Bind the value to an index.
|
void |
bind(int index,
byte[] value)
Bind the value to an index.
|
void |
bind(int index,
double value)
Bind the value to an index.
|
void |
bind(int index,
float value)
Bind the value to an index.
|
void |
bind(int index,
int value)
Bind the value to an index.
|
void |
bind(int index,
long value)
Bind the value to an index.
|
void |
bind(int index,
java.lang.String value)
Bind the value to an index.
|
void |
bindNull(int index)
Bind null to an index.
|
void |
close()
Close this object and release any resources associated with
it.
|
long |
execute()
Execute the previously prepared insert or replace using the bound values
since the last call to prepareForInsert or prepareForReplace.
|
int |
getColumnIndex(java.lang.String key)
Returns the index of the specified column.
|
long |
insert(ContentValues values)
Performs an insert, adding a new row with the given values.
|
void |
prepareForInsert()
Prepare the InsertHelper for an insert.
|
void |
prepareForReplace()
Prepare the InsertHelper for a replace.
|
long |
replace(ContentValues values)
Performs an insert, adding a new row with the given values.
|
public static final int TABLE_INFO_PRAGMA_COLUMNNAME_INDEX
public static final int TABLE_INFO_PRAGMA_DEFAULT_INDEX
public DatabaseUtils.InsertHelper(SQLiteDatabase db, java.lang.String tableName)
db
- the SQLiteDatabase to insert intotableName
- the name of the table to insert intopublic int getColumnIndex(java.lang.String key)
key
- the column namepublic void bind(int index, double value)
index
- the index of the slot to which to bindvalue
- the value to bindpublic void bind(int index, float value)
index
- the index of the slot to which to bindvalue
- the value to bindpublic void bind(int index, long value)
index
- the index of the slot to which to bindvalue
- the value to bindpublic void bind(int index, int value)
index
- the index of the slot to which to bindvalue
- the value to bindpublic void bind(int index, boolean value)
index
- the index of the slot to which to bindvalue
- the value to bindpublic void bindNull(int index)
index
- the index of the slot to which to bindpublic void bind(int index, byte[] value)
index
- the index of the slot to which to bindvalue
- the value to bindpublic void bind(int index, java.lang.String value)
index
- the index of the slot to which to bindvalue
- the value to bindpublic long insert(ContentValues values)
values
- the set of values with which to populate the
new rowpublic long execute()
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().
public void prepareForInsert()
public void prepareForReplace()
public long replace(ContentValues values)
values
- the set of values with which to populate the
new rowpublic void close()
insert()
after
calling this method is undefined.