Java Code Examples for android.database.sqlite.SQLiteStatement.simpleQueryForLong()

The following are Jave code examples for showing how to use simpleQueryForLong() of the android.database.sqlite.SQLiteStatement class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: weex-3d-map   File: DefaultWXStorage.java   Source Code and License Vote up 6 votes
private long performGetLength() {
    SQLiteDatabase database = mDatabaseSupplier.getDatabase();
    if (database == null) {
        return 0;
    }

    String sql = "SELECT count(" + WXSQLiteOpenHelper.COLUMN_KEY + ") FROM " + WXSQLiteOpenHelper.TABLE_STORAGE;
    SQLiteStatement statement = null;
    try {
        statement = database.compileStatement(sql);
        return statement.simpleQueryForLong();
    } catch (Exception e) {
        WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute getLength:" + e.getMessage());
        return 0;
    } finally {
        if(statement != null) {
            statement.close();
        }
    }
}
 
Example 2
Project: ucar-weex-core   File: DefaultWXStorage.java   Source Code and License Vote up 6 votes
private long performGetLength() {
    SQLiteDatabase database = mDatabaseSupplier.getDatabase();
    if (database == null) {
        return 0;
    }

    String sql = "SELECT count(" + WXSQLiteOpenHelper.COLUMN_KEY + ") FROM " + WXSQLiteOpenHelper.TABLE_STORAGE;
    SQLiteStatement statement = null;
    try {
        statement = database.compileStatement(sql);
        return statement.simpleQueryForLong();
    } catch (Exception e) {
        WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute getLength:" + e.getMessage());
        return 0;
    } finally {
        if(statement != null) {
            statement.close();
        }
    }
}
 
Example 3
Project: Cash   File: tblProdutos.java   Source Code and License Vote up 6 votes
public String getCalcFornecedor() {
    try {
        Long lAux;

        SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement(
                "SELECT id_compra FROM compra_itens WHERE" +
                        " id_produto = " + String.valueOf(getIdProduto()) +
                        " ORDER BY dt_compra_inv DESC LIMIT 1"
        );

        lAux = sStatement.simpleQueryForLong();
        tblCompras record = new tblCompras();
        record.getRecord(lAux.intValue());

        return record.getCalcNomeFornecedor();
    } catch (Exception e) {
        return "";
    }
}
 
Example 4
Project: buildAPKsApps   File: DataManager.java   Source Code and License Vote up 5 votes
private int countItemsInList(SQLiteDatabase db, int listId)
{
    SQLiteStatement stmt = db.compileStatement("select count(*) from items where list_id=?");        
    stmt.bindLong(1, listId);
    int rv = (int)stmt.simpleQueryForLong();
    stmt.close();
    
    return rv;
}
 
Example 5
Project: buildAPKsApps   File: DataManager.java   Source Code and License Vote up 5 votes
private int countInactiveItemsInList(SQLiteDatabase db, int listId)
{
    SQLiteStatement stmt = db.compileStatement("select count(*) from items where list_id=? and active=1");        
    stmt.bindLong(1, listId);
    int rv = (int)stmt.simpleQueryForLong();
    stmt.close();
    
    return rv;
}
 
Example 6
Project: unity-obb-downloader   File: DownloadsDB.java   Source Code and License Vote up 5 votes
public long getIDByIndex(int index) {
    SQLiteStatement downloadByIndex = getDownloadByIndexStatement();
    downloadByIndex.clearBindings();
    downloadByIndex.bindLong(1, index);
    try {
        return downloadByIndex.simpleQueryForLong();
    } catch (SQLiteDoneException e) {
        return -1;
    }
}
 
Example 7
Project: SlotNSlot_Android   File: DownloadsDB.java   Source Code and License Vote up 5 votes
public long getIDByIndex(int index) {
    SQLiteStatement downloadByIndex = getDownloadByIndexStatement();
    downloadByIndex.clearBindings();
    downloadByIndex.bindLong(1, index);
    try {
        return downloadByIndex.simpleQueryForLong();
    } catch (SQLiteDoneException e) {
        return -1;
    }
}
 
Example 8
Project: Cash   File: tblVendas.java   Source Code and License Vote up 5 votes
public int getCalcQtdeItensVenda() {
    try {
        SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT COUNT(id_venda_item) FROM venda_itens WHERE id_venda = " + String.valueOf(getIdVenda()));
        return (int) sStatement.simpleQueryForLong();
    } catch (Exception e) {
        return 0;
    }
}
 
Example 9
Project: Cash   File: tblCompras.java   Source Code and License Vote up 5 votes
public int getCalcQtdeItensCompra() {
    try {
        SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT COUNT(id_compra_item) FROM compra_itens WHERE id_compra = " + String.valueOf(getIdCompra()));
        return (int) sStatement.simpleQueryForLong();
    } catch (Exception e) {
        return 0;
    }
}
 
Example 10
Project: YuiHatano   File: ShadowDatabaseUtils.java   Source Code and License Vote up 4 votes
/**
 * Utility method to run the pre-compiled query and return the value in the
 * first column of the first row.
 */
public static long longForQuery(SQLiteStatement prog, String[] selectionArgs) {
    prog.bindAllArgsAsStrings(selectionArgs);
    return prog.simpleQueryForLong();
}
 
Example 11
Project: PokerBankroll   File: tblTorneios.java   Source Code and License Vote up 4 votes
private void setIdTorneio() {
    SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT MAX(id_torneio) FROM " + mTable);
    this.idTorneio = (int) sStatement.simpleQueryForLong() + 1;
}
 
Example 12
Project: PokerBankroll   File: tblMovimentos.java   Source Code and License Vote up 4 votes
private void setIdMovimento() {
    SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT MAX(id_movimento) FROM " + mTable);
    this.idMovimento = (int) sStatement.simpleQueryForLong() + 1;
}
 
Example 13
Project: KBUnitTest   File: ShadowDatabaseUtils.java   Source Code and License Vote up 4 votes
/**
 * Utility method to run the pre-compiled query and return the value in the
 * first column of the first row.
 */
public static long longForQuery(SQLiteStatement prog, String[] selectionArgs) {
    prog.bindAllArgsAsStrings(selectionArgs);
    return prog.simpleQueryForLong();
}
 
Example 14
Project: Cash   File: tblRecebimentos.java   Source Code and License Vote up 4 votes
private void setIdRecebimento() {
    SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT MAX(id_recebimento) FROM " + mTable);
    this.idRecebimento = (int) sStatement.simpleQueryForLong() + 1;
}
 
Example 15
Project: Cash   File: tblCompraItens.java   Source Code and License Vote up 4 votes
private void setIdItem() {
    SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT MAX(id_compra_item) FROM " + mTable);
    this.idCompraItem = (int) sStatement.simpleQueryForLong() + 1;
}
 
Example 16
Project: Cash   File: tblVendaRecebimentos.java   Source Code and License Vote up 4 votes
private void setIdRecebimento() {
    SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT MAX(id_venda_recebimento) FROM " + mTable);
    this.idVendaRecebimento = (int) sStatement.simpleQueryForLong() + 1;
}
 
Example 17
Project: Cash   File: tblGruposProduto.java   Source Code and License Vote up 4 votes
private void setIdGrupoProduto() {
    SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT MAX(id_grupo_produto) FROM " + mTable);
    this.idGrupoProduto = (int) sStatement.simpleQueryForLong() + 1;
}
 
Example 18
Project: Cash   File: tblFornecedores.java   Source Code and License Vote up 4 votes
private void setidFornecedor() {
    SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT MAX(id_fornecedor) FROM " + mTable);
    this.idFornecedor = (int) sStatement.simpleQueryForLong() + 1;
}
 
Example 19
Project: Cash   File: tblCompraPagamentos.java   Source Code and License Vote up 4 votes
private void setIdPagamento() {
    SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT MAX(id_compra_pagamento) FROM " + mTable);
    this.idCompraPagamento = (int) sStatement.simpleQueryForLong() + 1;
}
 
Example 20
Project: Cash   File: tblClientes.java   Source Code and License Vote up 4 votes
private void setIdCliente() {
    SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("SELECT MAX(id_cliente) FROM " + mTable);
    this.idCliente = (int) sStatement.simpleQueryForLong() + 1;
}