Code example for SQLiteDatabase

Methods: compileStatement

0
        return post;
    } 
 
    public int getNumberOfPosts() { 
        final SQLiteDatabase db = openHelper.getReadableDatabase();
        final SQLiteStatement statement = db.compileStatement("select count(*) from " + DATABASE_TABLE + ";");
        return (int) (statement.simpleQueryForLong());
    } 
 
    public boolean exists(String key) {
        final SQLiteDatabase db = openHelper.getReadableDatabase();
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        qb.setTables(DATABASE_TABLE);
        Cursor c = qb.query(db, new String[]{COL_KEY}, COL_KEY + " = ?", new String[]{key}, null, null, null);
        try { 
            return c.moveToFirst();
        } finally { 
            c.close();
        } 
    } 
Experience pair programming with AI  Get Codota for Java