dimanche 31 mai 2015

Android ORMLite create or Update statment block to update

i want to simulate Sqlite command as INSERT OR UPDATE with ORMlite library,i'm trying this link to get help to updte msg_id column if exist in database,but i can not.

List<MessagesList> id = G.messagesListsDao.queryForEq("msg_id", msg_id);
if (id == null) {
    G.messagesListsDao.create(
            new MessagesList(
                    0,
                    msg_id,
                    user_eitaa_id,
                    group_id,
                    msg_title,
                    msg_content,
                    msg_type,
                    stream_link,
                    preview_image_url,
                    msg_admin,
                    received_date,
                    avatar_url
            )
    );
} else {
    G.messagesListsDao.update(
            new MessagesList(
                    id.get(0).getId(),
                    msg_id,
                    user_eitaa_id,
                    group_id,
                    msg_title,
                    msg_content,
                    msg_type,
                    stream_link,
                    preview_image_url,
                    msg_admin,
                    received_date,
                    avatar_url
            )
    );
}
} catch (JSONException e) {
}

with G.messagesListsDao.queryForEq i'm trying to search msg_id, if exist in database must be update otherwise create new. i can not do it. please help me

Aucun commentaire:

Enregistrer un commentaire