SQLiteStatementpublic class SQLiteStatement extends SQLiteProgram A pre-compiled statement against a {@link SQLiteDatabase} that can be reused.
The statement cannot return multiple rows, but 1x1 result sets are allowed.
Don't use SQLiteStatement constructor directly, please use
{@link SQLiteDatabase#compileStatement(String)} |
Fields Summary |
---|
private static final String | TAG | private final String | mSql |
Constructors Summary |
---|
SQLiteStatement(SQLiteDatabase db, String sql)Don't use SQLiteStatement constructor directly, please use
{@link SQLiteDatabase#compileStatement(String)}
/* package */
super(db, sql);
if (SQLiteDebug.DEBUG_SQL_STATEMENTS) {
mSql = sql;
} else {
mSql = null;
}
|
Methods Summary |
---|
public void | execute()Execute this SQL statement, if it is not a query. For example,
CREATE TABLE, DELTE, INSERT, etc.
mDatabase.lock();
boolean logStats = mDatabase.mLogStats;
long startTime = logStats ? SystemClock.elapsedRealtime() : 0;
acquireReference();
try {
if (SQLiteDebug.DEBUG_SQL_STATEMENTS) {
Log.v(TAG, "execute() for [" + mSql + "]");
}
native_execute();
if (logStats) {
mDatabase.logTimeStat(false /* write */, startTime, SystemClock.elapsedRealtime());
}
} finally {
releaseReference();
mDatabase.unlock();
}
| public long | executeInsert()Execute this SQL statement and return the ID of the most
recently inserted row. The SQL statement should probably be an
INSERT for this to be a useful call.
mDatabase.lock();
boolean logStats = mDatabase.mLogStats;
long startTime = logStats ? SystemClock.elapsedRealtime() : 0;
acquireReference();
try {
if (SQLiteDebug.DEBUG_SQL_STATEMENTS) {
Log.v(TAG, "executeInsert() for [" + mSql + "]");
}
native_execute();
if (logStats) {
mDatabase.logTimeStat(false /* write */, startTime, SystemClock.elapsedRealtime());
}
return mDatabase.lastInsertRow();
} finally {
releaseReference();
mDatabase.unlock();
}
| private final native long | native_1x1_long()
| private final native java.lang.String | native_1x1_string()
| private final native void | native_execute()
| public long | simpleQueryForLong()Execute a statement that returns a 1 by 1 table with a numeric value.
For example, SELECT COUNT(*) FROM table;
mDatabase.lock();
boolean logStats = mDatabase.mLogStats;
long startTime = logStats ? SystemClock.elapsedRealtime() : 0;
acquireReference();
try {
if (SQLiteDebug.DEBUG_SQL_STATEMENTS) {
Log.v(TAG, "simpleQueryForLong() for [" + mSql + "]");
}
long retValue = native_1x1_long();
if (logStats) {
mDatabase.logTimeStat(false /* write */, startTime, SystemClock.elapsedRealtime());
}
return retValue;
} finally {
releaseReference();
mDatabase.unlock();
}
| public java.lang.String | simpleQueryForString()Execute a statement that returns a 1 by 1 table with a text value.
For example, SELECT COUNT(*) FROM table;
mDatabase.lock();
boolean logStats = mDatabase.mLogStats;
long startTime = logStats ? SystemClock.elapsedRealtime() : 0;
acquireReference();
try {
if (SQLiteDebug.DEBUG_SQL_STATEMENTS) {
Log.v(TAG, "simpleQueryForString() for [" + mSql + "]");
}
String retValue = native_1x1_string();
if (logStats) {
mDatabase.logTimeStat(false /* write */, startTime, SystemClock.elapsedRealtime());
}
return retValue;
} finally {
releaseReference();
mDatabase.unlock();
}
|
|