Code example for SQLiteDatabase

Methods: insertOrThrow

0
        DatabaseHelper.trace(true, "PresenceTable.create()"); 
        if (writableDb == null) {
            throw new NullPointerException(DEFAULT_ERROR_MESSAGE);
        } 
 
        if (!conversationIdExists(msg.getConversationId(), writableDb)) {
 
            // remove old conversation for this user if it existed 
 
            removeOldConversationByLocalContactIdAndNetworkId(msg.getLocalContactId(), msg
                    .getNetworkId(), writableDb);
 
            ContentValues values = new ContentValues();
            values.put(Field.CONVERSATION_ID.toString(), msg.getConversationId());
            values.put(Field.LOCALCONTACT_ID.toString(), msg.getLocalContactId());
            values.put(Field.USER_ID.toString(), msg.getUserId());
            values.put(Field.NETWORK_ID.toString(), msg.getNetworkId());
            values.put(Field.LATEST_MESSAGE.toString(), System.currentTimeMillis());
            writableDb.insertOrThrow(TABLE_NAME, null, values);
 
            values.clear();
        } 
    }