Java Code Examples for android.database.sqlite.SQLiteStatement#bindAllArgsAsStrings()

The following examples show how to use android.database.sqlite.SQLiteStatement#bindAllArgsAsStrings() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
public void log(String url, String req, String resp) {
    SQLiteDatabase db = null;
    SQLiteStatement statement;
    long timestamp;
    try {
        db = getWritableDatabase();
        db.beginTransaction();
        statement = db.compileStatement("INSERT INTO ".concat(packetlog_table_name).concat(" (timestamp, url, type, data) values (?, ?, ?, ?)"));

        timestamp = System.currentTimeMillis();
        statement.bindAllArgsAsStrings(new String[]{String.valueOf(timestamp), url, REQUEST, req});
        statement.execute();

        timestamp = System.currentTimeMillis();
        statement.bindAllArgsAsStrings(new String[]{String.valueOf(timestamp), url, RESPONSE, resp});
        statement.execute();

        statement.close();
        db.setTransactionSuccessful();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        if (db != null) {
            db.endTransaction();
        }
    }
}
 
Example 2
public void log(String url, String req, String resp) {
    SQLiteDatabase db = null;
    SQLiteStatement statement;
    long timestamp;
    try {
        db = getWritableDatabase();
        db.beginTransaction();
        statement = db.compileStatement("INSERT INTO ".concat(packetlog_table_name).concat(" (timestamp, url, type, data) values (?, ?, ?, ?)"));

        timestamp = System.currentTimeMillis();
        statement.bindAllArgsAsStrings(new String[]{String.valueOf(timestamp), url, REQUEST, req});
        statement.execute();

        timestamp = System.currentTimeMillis();
        statement.bindAllArgsAsStrings(new String[]{String.valueOf(timestamp), url, RESPONSE, resp});
        statement.execute();

        statement.close();
        db.setTransactionSuccessful();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        if (db != null) {
            db.endTransaction();
        }
    }
}
 
Example 3
Source Project: android_9.0.0_r45   File: DatabaseUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 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 4
Source Project: android_9.0.0_r45   File: DatabaseUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Utility method to run the pre-compiled query and return the value in the
 * first column of the first row.
 */
public static String stringForQuery(SQLiteStatement prog, String[] selectionArgs) {
    prog.bindAllArgsAsStrings(selectionArgs);
    return prog.simpleQueryForString();
}
 
Example 5
Source Project: android_9.0.0_r45   File: DatabaseUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Utility method to run the pre-compiled query and return the blob value in the
 * first column of the first row.
 *
 * @return A read-only file descriptor for a copy of the blob value.
 */
public static ParcelFileDescriptor blobFileDescriptorForQuery(SQLiteStatement prog,
        String[] selectionArgs) {
    prog.bindAllArgsAsStrings(selectionArgs);
    return prog.simpleQueryForBlobFileDescriptor();
}
 
Example 6
Source Project: twitt4droid   File: SQLiteUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Calls the native bindAllArgsAsStrings method in the given SQLiteStatement.
 * 
 * @param statement a SQLiteStatement
 * @param bindArgs the arguments.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static void nativeBindAllArgsAsStrings(SQLiteStatement statement, String[] bindArgs) {
    statement.bindAllArgsAsStrings(bindArgs);
}