FileDocCategorySizeDatePackage
SQLiteStatement.javaAPI DocAndroid 5.1 API5486Thu Mar 12 22:22:10 GMT 2015android.database.sqlite

SQLiteStatement

public final class SQLiteStatement extends SQLiteProgram
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.

Fields Summary
Constructors Summary
SQLiteStatement(SQLiteDatabase db, String sql, Object[] bindArgs)

        super(db, sql, bindArgs, null);
    
Methods Summary
public voidexecute()
Execute this SQL statement, if it is not a SELECT / INSERT / DELETE / UPDATE, for example CREATE / DROP table, view, trigger, index etc.

throws
android.database.SQLException If the SQL string is invalid for some reason

        acquireReference();
        try {
            getSession().execute(getSql(), getBindArgs(), getConnectionFlags(), null);
        } catch (SQLiteDatabaseCorruptException ex) {
            onCorruption();
            throw ex;
        } finally {
            releaseReference();
        }
    
public longexecuteInsert()
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.

return
the row ID of the last row inserted, if this insert is successful. -1 otherwise.
throws
android.database.SQLException If the SQL string is invalid for some reason

        acquireReference();
        try {
            return getSession().executeForLastInsertedRowId(
                    getSql(), getBindArgs(), getConnectionFlags(), null);
        } catch (SQLiteDatabaseCorruptException ex) {
            onCorruption();
            throw ex;
        } finally {
            releaseReference();
        }
    
public intexecuteUpdateDelete()
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.

return
the number of rows affected by this SQL statement execution.
throws
android.database.SQLException If the SQL string is invalid for some reason

        acquireReference();
        try {
            return getSession().executeForChangedRowCount(
                    getSql(), getBindArgs(), getConnectionFlags(), null);
        } catch (SQLiteDatabaseCorruptException ex) {
            onCorruption();
            throw ex;
        } finally {
            releaseReference();
        }
    
public android.os.ParcelFileDescriptorsimpleQueryForBlobFileDescriptor()
Executes a statement that returns a 1 by 1 table with a blob value.

return
A read-only file descriptor for a copy of the blob value, or {@code null} if the value is null or could not be read for some reason.
throws
android.database.sqlite.SQLiteDoneException if the query returns zero rows

        acquireReference();
        try {
            return getSession().executeForBlobFileDescriptor(
                    getSql(), getBindArgs(), getConnectionFlags(), null);
        } catch (SQLiteDatabaseCorruptException ex) {
            onCorruption();
            throw ex;
        } finally {
            releaseReference();
        }
    
public longsimpleQueryForLong()
Execute a statement that returns a 1 by 1 table with a numeric value. For example, SELECT COUNT(*) FROM table;

return
The result of the query.
throws
android.database.sqlite.SQLiteDoneException if the query returns zero rows

        acquireReference();
        try {
            return getSession().executeForLong(
                    getSql(), getBindArgs(), getConnectionFlags(), null);
        } catch (SQLiteDatabaseCorruptException ex) {
            onCorruption();
            throw ex;
        } finally {
            releaseReference();
        }
    
public java.lang.StringsimpleQueryForString()
Execute a statement that returns a 1 by 1 table with a text value. For example, SELECT COUNT(*) FROM table;

return
The result of the query.
throws
android.database.sqlite.SQLiteDoneException if the query returns zero rows

        acquireReference();
        try {
            return getSession().executeForString(
                    getSql(), getBindArgs(), getConnectionFlags(), null);
        } catch (SQLiteDatabaseCorruptException ex) {
            onCorruption();
            throw ex;
        } finally {
            releaseReference();
        }
    
public java.lang.StringtoString()

        return "SQLiteProgram: " + getSql();