Example usage for android.database.sqlite SQLiteStatement simpleQueryForLong

List of usage examples for android.database.sqlite SQLiteStatement simpleQueryForLong

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteStatement simpleQueryForLong.

Prototype

public long simpleQueryForLong() 

Source Link

Document

Execute a statement that returns a 1 by 1 table with a numeric value.

Usage

From source file:android.database.DatabaseUtils.java

/**
 * Utility method to run the pre-compiled query and return the value in the
 * first column of the first row./*w w w  . j a  va  2  s .co  m*/
 */
public static long longForQuery(SQLiteStatement prog, String[] selectionArgs) {
    if (selectionArgs != null) {
        int size = selectionArgs.length;
        for (int i = 0; i < size; i++) {
            bindObjectToProgram(prog, i + 1, selectionArgs[i]);
        }
    }
    long value = prog.simpleQueryForLong();
    return value;
}

From source file:org.kontalk.provider.UsersProvider.java

private int executeUpdateDelete(SQLiteDatabase db, SQLiteStatement stm) {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        return stm.executeUpdateDelete();
    } else {//from  w ww  .  j  av a2s  .c  om
        stm.execute();
        SQLiteStatement changes = db.compileStatement("SELECT changes()");
        try {
            return (int) changes.simpleQueryForLong();
        } finally {
            changes.close();
        }
    }
}

From source file:io.requery.android.database.sqlite.SQLiteDatabase.java

/**
 * Utility method to run the pre-compiled query and return the value in the
 * first column of the first row.//from   w  w w .  j  a  v  a  2s.  c  o m
 */
private static long longForQuery(SQLiteStatement prog, String[] selectionArgs) {
    prog.bindAllArgsAsStrings(selectionArgs);
    return prog.simpleQueryForLong();
}