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

The following examples show how to use android.database.sqlite.SQLiteStatement#bindAllArgsAsStrings() . 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 check out the related API usage on the sidebar.
Example 1
Source File: KcaPacketLogger.java    From kcanotify_h5-master with GNU General Public License v3.0 5 votes vote down vote up
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
Source File: KcaPacketLogger.java    From kcanotify with GNU General Public License v3.0 5 votes vote down vote up
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 File: DatabaseUtils.java    From android_9.0.0_r45 with 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 File: DatabaseUtils.java    From android_9.0.0_r45 with 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 File: DatabaseUtils.java    From android_9.0.0_r45 with 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 File: SQLiteUtils.java    From twitt4droid with 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);
}