Code example for SQLiteDatabase

Methods: replace

0
        ContentValues initialValues = new ContentValues();
        initialValues.put(KEY_REFERENCE, String.valueOf(reference));
        initialValues.put(KEY_VERSION, version);
        initialValues.put(KEY_NOTIFIED_AT, dateFormat.format(date));
 
        return mDb.replace(DATABASE_TABLE, null, initialValues);
    } 
 
    /** 
     * Fetch a entry by it's reference. 
     * @param type the type 
     * @param name the name 
     * @return a Cursor object positioned at the first entry 
     */ 
    public boolean containsReference(long reference, int version) {
        Cursor mCursor =
            mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_REFERENCE},
                    KEY_REFERENCE + "=\"" + reference + "\" "
                    + "AND " + KEY_VERSION + "=" + version, 
                    null, null, null, null, null);