Code example for SQLiteStatement

Methods: closebindStringexecutetoString

0
 
    public boolean setPersistentSetting(String settingName, String value) {
        SQLiteDatabase db = getWritableDatabase();
        SQLiteStatement stmt = db.compileStatement("UPDATE settings SET " + SettingsTableColumnNames.VALUE.getString() +
                " = ? WHERE " + SettingsTableColumnNames.NAME.getString() + " = ?"); 
        stmt.bindString(1, value);
        stmt.bindString(2, settingName);
 
        boolean success = false;
        db.beginTransaction();
        try 
        { 
            Log.d(TAG, "SqlStatement is " + stmt.toString());
            stmt.execute();
            db.setTransactionSuccessful();
            success = true;
        } 
        catch (SQLException ex)
        { 
            ex.printStackTrace();
        } 
        finally 
        { 
            db.endTransaction();
            stmt.close();
            db.close();
        } 
 
        return success;
 
Stop searching for code, let great code find you!  Add Codota to your java IDE