public class

SQLiteStatement

extends SQLiteProgram
java.lang.Object
   ↳ android.database.sqlite.SQLiteClosable
     ↳ android.database.sqlite.SQLiteProgram
       ↳ android.database.sqlite.SQLiteStatement

Class Overview

A pre-compiled statement against a 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 compileStatement(String)

SQLiteStatement is NOT internally synchronized so code using a SQLiteStatement from multiple threads should perform its own synchronization when using the SQLiteStatement.

Summary

[Expand]
Inherited Fields
From class android.database.sqlite.SQLiteProgram
Public Methods
void execute()
Execute this SQL statement, if it is not a SELECT / INSERT / DELETE / UPDATE, for example CREATE / DROP table, view, trigger, index etc.
long executeInsert()
Execute this SQL statement and return the ID of the row inserted due to this call.
int executeUpdateDelete()
Execute this SQL statement, if the the number of rows affected by execution of this SQL statement is of any importance to the caller - for example, UPDATE / DELETE SQL statements.
ParcelFileDescriptor simpleQueryForBlobFileDescriptor()
Executes a statement that returns a 1 by 1 table with a blob value.
long simpleQueryForLong()
Execute a statement that returns a 1 by 1 table with a numeric value.
String simpleQueryForString()
Execute a statement that returns a 1 by 1 table with a text value.
[Expand]
Inherited Methods
From class android.database.sqlite.SQLiteProgram
From class android.database.sqlite.SQLiteClosable
From class java.lang.Object

Public Methods

public void execute ()

Since: API Level 1

Execute this SQL statement, if it is not a SELECT / INSERT / DELETE / UPDATE, for example CREATE / DROP table, view, trigger, index etc.

Throws
SQLException If the SQL string is invalid for some reason

public long executeInsert ()

Since: API Level 1

Execute this SQL statement and return the ID of the row inserted due to this call. The SQL statement should be an INSERT for this to be a useful call.

Returns
  • the row ID of the last row inserted, if this insert is successful. -1 otherwise.
Throws
SQLException If the SQL string is invalid for some reason

public int executeUpdateDelete ()

Since: API Level 11

Execute this SQL statement, if the the number of rows affected by execution of this SQL statement is of any importance to the caller - for example, UPDATE / DELETE SQL statements.

Returns
  • the number of rows affected by this SQL statement execution.
Throws
SQLException If the SQL string is invalid for some reason

public ParcelFileDescriptor simpleQueryForBlobFileDescriptor ()

Since: API Level 11

Executes a statement that returns a 1 by 1 table with a blob value.

Returns
  • A read-only file descriptor for a copy of the blob value, or null if the value is null or could not be read for some reason.
Throws
SQLiteDoneException if the query returns zero rows

public long simpleQueryForLong ()

Since: API Level 1

Execute a statement that returns a 1 by 1 table with a numeric value. For example, SELECT COUNT(*) FROM table;

Returns
  • The result of the query.
Throws
SQLiteDoneException if the query returns zero rows

public String simpleQueryForString ()

Since: API Level 1

Execute a statement that returns a 1 by 1 table with a text value. For example, SELECT COUNT(*) FROM table;

Returns
  • The result of the query.
Throws
SQLiteDoneException if the query returns zero rows