Most visited

Recently visited

Added in API level 1

SQLiteStatement

public final class SQLiteStatement
extends SQLiteProgram

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


Represents a statement that can be executed against a database. The statement cannot return multiple rows or columns, but single value (1 x 1) result sets are supported.

This class is not thread-safe.

Summary

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.

String toString()

Returns a string representation of the object.

Inherited methods

From class android.database.sqlite.SQLiteProgram
From class android.database.sqlite.SQLiteClosable
From class java.lang.Object
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public methods

execute

Added in API level 1
void execute ()

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

executeInsert

Added in API level 1
long executeInsert ()

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
long 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

executeUpdateDelete

Added in API level 11
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.

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

simpleQueryForBlobFileDescriptor

Added in API level 11
ParcelFileDescriptor simpleQueryForBlobFileDescriptor ()

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

Returns
ParcelFileDescriptor 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

simpleQueryForLong

Added in API level 1
long simpleQueryForLong ()

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

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

simpleQueryForString

Added in API level 1
String simpleQueryForString ()

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

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

toString

Added in API level 1
String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

Hooray!