Code example for ContentValues

Methods: containsKeygetAsByteArrayputNull

     * If a photo was specified but could not be processed, this will return false. 
     * @param values The content values passed in. 
     * @return Whether processing was successful - on failure, the operation should abort. 
    private boolean preProcessPhoto(ContentValues values) {
        if (values.containsKey(Photo.PHOTO)) {
            boolean photoExists = hasNonNullPhoto(values);
            if (photoExists) {
                if (!processPhoto(values)) {
                    // A photo was passed in, but we couldn't process it.  Update failed. 
                    return false; 
            } else { 
                // The photo key was passed in, but it was either null or an empty byte[]. 
                // We should set the photo and photo file ID fields to null for the update. 
        return true; 
    private boolean hasNonNullPhoto(ContentValues values) {
        byte[] photoBytes = values.getAsByteArray(Photo.PHOTO);
        return photoBytes != null && photoBytes.length > 0;
    public int delete(SQLiteDatabase db, TransactionContext txContext, Cursor c) {