Example usage for android.database.sqlite SQLiteDatabase update

List of usage examples for android.database.sqlite SQLiteDatabase update

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteDatabase update.

Prototype

public int update(String table, ContentValues values, String whereClause, String[] whereArgs) 

Source Link

Document

Convenience method for updating rows in the database.

Usage

From source file:org.frc836.database.DBSyncService.java

private void processEvents(JSONArray events) {
    try {/*from ww w  .ja va2  s . co m*/
        for (int i = 0; i < events.length(); i++) {
            JSONObject row = events.getJSONObject(i);
            Action action = Action.UPDATE;
            if (row.getInt(EVENT_LU_Entry.COLUMN_NAME_INVALID) != 0) {
                action = Action.DELETE;
            }
            ContentValues vals = new ContentValues();
            vals.put(EVENT_LU_Entry.COLUMN_NAME_ID, row.getInt(EVENT_LU_Entry.COLUMN_NAME_ID));
            vals.put(EVENT_LU_Entry.COLUMN_NAME_EVENT_NAME,
                    row.getString(EVENT_LU_Entry.COLUMN_NAME_EVENT_NAME));
            vals.put(EVENT_LU_Entry.COLUMN_NAME_EVENT_CODE,
                    row.getString(EVENT_LU_Entry.COLUMN_NAME_EVENT_CODE));
            vals.put(EVENT_LU_Entry.COLUMN_NAME_DATE_START,
                    row.getString(EVENT_LU_Entry.COLUMN_NAME_DATE_START));
            vals.put(EVENT_LU_Entry.COLUMN_NAME_TIMESTAMP,
                    DB.dateParser.format(new Date(row.getLong(EVENT_LU_Entry.COLUMN_NAME_TIMESTAMP) * 1000)));

            // check if this entry exists already
            String[] projection = { EVENT_LU_Entry.COLUMN_NAME_EVENT_NAME };
            String[] where = { vals.getAsString(EVENT_LU_Entry.COLUMN_NAME_ID) };
            synchronized (ScoutingDBHelper.lock) {

                SQLiteDatabase db = ScoutingDBHelper.getInstance().getWritableDatabase();

                Cursor c = db.query(EVENT_LU_Entry.TABLE_NAME, projection, // select
                        EVENT_LU_Entry.COLUMN_NAME_ID + "=?", where, null, // don't
                        // group
                        null, // don't filter
                        null, // don't order
                        "0,1"); // limit to 1
                try {
                    if (!c.moveToFirst()) {
                        if (action == Action.UPDATE)
                            action = Action.INSERT;
                        else if (action == Action.DELETE)
                            action = Action.NOTHING;
                    }

                    switch (action) {
                    case UPDATE:
                        db.update(EVENT_LU_Entry.TABLE_NAME, vals, EVENT_LU_Entry.COLUMN_NAME_ID + " = ?",
                                where);
                        break;
                    case INSERT:
                        db.insert(EVENT_LU_Entry.TABLE_NAME, null, vals);
                        break;
                    case DELETE:
                        db.delete(EVENT_LU_Entry.TABLE_NAME, EVENT_LU_Entry.COLUMN_NAME_ID + " = ?", where);
                        break;
                    default:
                    }
                } finally {
                    if (c != null)
                        c.close();
                    ScoutingDBHelper.getInstance().close();
                }
            }

        }
    } catch (JSONException e) {
        // TODO handle error
    }
}

From source file:org.frc836.database.DBSyncService.java

private void processRobots(JSONArray robots) {
    try {/*from w  ww.  ja v a 2 s  .  c  om*/
        for (int i = 0; i < robots.length(); i++) {
            JSONObject row = robots.getJSONObject(i);
            Action action = Action.UPDATE;
            if (row.getInt(ROBOT_LU_Entry.COLUMN_NAME_INVALID) != 0) {
                action = Action.DELETE;
            }
            ContentValues vals = new ContentValues();
            vals.put(ROBOT_LU_Entry.COLUMN_NAME_ID, row.getInt(ROBOT_LU_Entry.COLUMN_NAME_ID));
            vals.put(ROBOT_LU_Entry.COLUMN_NAME_TEAM_ID, row.getString(ROBOT_LU_Entry.COLUMN_NAME_TEAM_ID));
            vals.put(ROBOT_LU_Entry.COLUMN_NAME_ROBOT_PHOTO,
                    row.getString(ROBOT_LU_Entry.COLUMN_NAME_ROBOT_PHOTO));
            vals.put(ROBOT_LU_Entry.COLUMN_NAME_TIMESTAMP,
                    DB.dateParser.format(new Date(row.getLong(ROBOT_LU_Entry.COLUMN_NAME_TIMESTAMP) * 1000)));

            // check if this entry exists already
            String[] projection = { ROBOT_LU_Entry.COLUMN_NAME_ID };
            String[] where = { vals.getAsString(ROBOT_LU_Entry.COLUMN_NAME_TEAM_ID) };
            synchronized (ScoutingDBHelper.lock) {

                SQLiteDatabase db = ScoutingDBHelper.getInstance().getWritableDatabase();

                Cursor c = db.query(ROBOT_LU_Entry.TABLE_NAME, projection, // select
                        ROBOT_LU_Entry.COLUMN_NAME_TEAM_ID + "=?", where, null, // don't
                        // group
                        null, // don't filter
                        null, // don't order
                        "0,1"); // limit to 1
                try {
                    if (!c.moveToFirst()) {
                        if (action == Action.UPDATE)
                            action = Action.INSERT;
                        else if (action == Action.DELETE)
                            action = Action.NOTHING;
                    }

                    switch (action) {
                    case UPDATE:
                        db.update(ROBOT_LU_Entry.TABLE_NAME, vals, ROBOT_LU_Entry.COLUMN_NAME_TEAM_ID + " = ?",
                                where);
                        break;
                    case INSERT:
                        db.insert(ROBOT_LU_Entry.TABLE_NAME, null, vals);
                        break;
                    case DELETE:
                        db.delete(ROBOT_LU_Entry.TABLE_NAME, ROBOT_LU_Entry.COLUMN_NAME_TEAM_ID + " = ?",
                                where);
                        break;
                    default:
                    }
                } finally {
                    if (c != null)
                        c.close();
                    ScoutingDBHelper.getInstance().close();
                }
            }
        }
    } catch (JSONException e) {
        // TODO handle error
    }
}

From source file:org.frc836.database.DBSyncService.java

private void processPositions(JSONArray positions) {
    try {/*from w ww  .j  a va  2s . c  o  m*/
        for (int i = 0; i < positions.length(); i++) {
            JSONObject row = positions.getJSONObject(i);
            Action action = Action.UPDATE;
            if (row.getInt(POSITION_LU_Entry.COLUMN_NAME_INVALID) != 0) {
                action = Action.DELETE;
            }
            ContentValues vals = new ContentValues();
            vals.put(POSITION_LU_Entry.COLUMN_NAME_ID, row.getInt(POSITION_LU_Entry.COLUMN_NAME_ID));
            vals.put(POSITION_LU_Entry.COLUMN_NAME_POSITION,
                    row.getString(POSITION_LU_Entry.COLUMN_NAME_POSITION));
            vals.put(POSITION_LU_Entry.COLUMN_NAME_TIMESTAMP, DB.dateParser
                    .format(new Date(row.getLong(POSITION_LU_Entry.COLUMN_NAME_TIMESTAMP) * 1000)));

            // check if this entry exists already
            String[] projection = { POSITION_LU_Entry.COLUMN_NAME_POSITION };
            String[] where = { vals.getAsString(POSITION_LU_Entry.COLUMN_NAME_ID) };

            synchronized (ScoutingDBHelper.lock) {

                SQLiteDatabase db = ScoutingDBHelper.getInstance().getWritableDatabase();

                Cursor c = db.query(POSITION_LU_Entry.TABLE_NAME, projection, // select
                        POSITION_LU_Entry.COLUMN_NAME_ID + "=?", where, null, // don't
                        // group
                        null, // don't filter
                        null, // don't order
                        "0,1"); // limit to 1
                try {
                    if (!c.moveToFirst()) {
                        if (action == Action.UPDATE)
                            action = Action.INSERT;
                        else if (action == Action.DELETE)
                            action = Action.NOTHING;
                    }

                    switch (action) {
                    case UPDATE:
                        db.update(POSITION_LU_Entry.TABLE_NAME, vals, POSITION_LU_Entry.COLUMN_NAME_ID + " = ?",
                                where);
                        break;
                    case INSERT:
                        db.insert(POSITION_LU_Entry.TABLE_NAME, null, vals);
                        break;
                    case DELETE:
                        db.delete(POSITION_LU_Entry.TABLE_NAME, POSITION_LU_Entry.COLUMN_NAME_ID + " = ?",
                                where);
                        break;
                    default:
                    }
                } finally {
                    if (c != null)
                        c.close();
                    ScoutingDBHelper.getInstance().close();
                }
            }
        }
    } catch (JSONException e) {
        // TODO handle error
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.DBHelper.java

void updateJsonAndRaw(SQLiteDatabase db, long id, String json, byte[] raw) {
    ContentValues cv = new ContentValues();
    cv.put(DbObject.JSON, json);/*from  w ww . ja v a  2 s .c o m*/
    cv.put(DbObject.RAW, raw);
    db.update(DbObject.TABLE, cv, DbObject._ID + " = ?", new String[] { String.valueOf(id) });
}

From source file:org.frc836.database.DBSyncService.java

private void processNotes(JSONArray notes) {
    try {/* www. j  ava 2  s . c  o m*/
        for (int i = 0; i < notes.length(); i++) {
            JSONObject row = notes.getJSONObject(i);
            Action action = Action.UPDATE;
            if (row.getInt(NOTES_OPTIONS_Entry.COLUMN_NAME_INVALID) != 0) {
                action = Action.DELETE;
            }
            ContentValues vals = new ContentValues();
            vals.put(NOTES_OPTIONS_Entry.COLUMN_NAME_ID, row.getInt(NOTES_OPTIONS_Entry.COLUMN_NAME_ID));
            vals.put(NOTES_OPTIONS_Entry.COLUMN_NAME_OPTION_TEXT,
                    row.getString(NOTES_OPTIONS_Entry.COLUMN_NAME_OPTION_TEXT));
            vals.put(NOTES_OPTIONS_Entry.COLUMN_NAME_TIMESTAMP, DB.dateParser
                    .format(new Date(row.getLong(NOTES_OPTIONS_Entry.COLUMN_NAME_TIMESTAMP) * 1000)));

            // check if this entry exists already
            String[] projection = { NOTES_OPTIONS_Entry.COLUMN_NAME_OPTION_TEXT };
            String[] where = { vals.getAsString(NOTES_OPTIONS_Entry.COLUMN_NAME_ID) };

            synchronized (ScoutingDBHelper.lock) {

                SQLiteDatabase db = ScoutingDBHelper.getInstance().getWritableDatabase();

                Cursor c = db.query(NOTES_OPTIONS_Entry.TABLE_NAME, projection, // select
                        NOTES_OPTIONS_Entry.COLUMN_NAME_ID + "=?", where, null, // don't
                        // group
                        null, // don't filter
                        null, // don't order
                        "0,1"); // limit to 1
                try {
                    if (!c.moveToFirst()) {
                        if (action == Action.UPDATE)
                            action = Action.INSERT;
                        else if (action == Action.DELETE)
                            action = Action.NOTHING;
                    }

                    switch (action) {
                    case UPDATE:
                        db.update(NOTES_OPTIONS_Entry.TABLE_NAME, vals,
                                NOTES_OPTIONS_Entry.COLUMN_NAME_ID + " = ?", where);
                        break;
                    case INSERT:
                        db.insert(NOTES_OPTIONS_Entry.TABLE_NAME, null, vals);
                        break;
                    case DELETE:
                        db.delete(NOTES_OPTIONS_Entry.TABLE_NAME, NOTES_OPTIONS_Entry.COLUMN_NAME_ID + " = ?",
                                where);
                        break;
                    default:
                    }
                } finally {
                    if (c != null)
                        c.close();
                    ScoutingDBHelper.getInstance().close();
                }
            }
        }
    } catch (JSONException e) {
        // TODO handle error
    }
}

From source file:org.frc836.database.DBSyncService.java

private void processWheelBase(JSONArray wheelBase) {
    try {//  w  w  w. j  av  a2 s  .  c  o  m
        for (int i = 0; i < wheelBase.length(); i++) {
            JSONObject row = wheelBase.getJSONObject(i);
            Action action = Action.UPDATE;
            if (row.getInt(WHEEL_BASE_LU_Entry.COLUMN_NAME_INVALID) != 0) {
                action = Action.DELETE;
            }
            ContentValues vals = new ContentValues();
            vals.put(WHEEL_BASE_LU_Entry.COLUMN_NAME_ID, row.getInt(WHEEL_BASE_LU_Entry.COLUMN_NAME_ID));
            vals.put(WHEEL_BASE_LU_Entry.COLUMN_NAME_WHEEL_BASE_DESC,
                    row.getString(WHEEL_BASE_LU_Entry.COLUMN_NAME_WHEEL_BASE_DESC));
            vals.put(WHEEL_BASE_LU_Entry.COLUMN_NAME_TIMESTAMP, DB.dateParser
                    .format(new Date(row.getLong(WHEEL_BASE_LU_Entry.COLUMN_NAME_TIMESTAMP) * 1000)));

            // check if this entry exists already
            String[] projection = { WHEEL_BASE_LU_Entry.COLUMN_NAME_WHEEL_BASE_DESC };
            String[] where = { vals.getAsString(WHEEL_BASE_LU_Entry.COLUMN_NAME_ID) };

            synchronized (ScoutingDBHelper.lock) {

                SQLiteDatabase db = ScoutingDBHelper.getInstance().getWritableDatabase();

                Cursor c = db.query(WHEEL_BASE_LU_Entry.TABLE_NAME, projection, // select
                        WHEEL_BASE_LU_Entry.COLUMN_NAME_ID + "=?", where, null, // don't
                        // group
                        null, // don't filter
                        null, // don't order
                        "0,1"); // limit to 1
                try {
                    if (!c.moveToFirst()) {
                        if (action == Action.UPDATE)
                            action = Action.INSERT;
                        else if (action == Action.DELETE)
                            action = Action.NOTHING;
                    }

                    switch (action) {
                    case UPDATE:
                        db.update(WHEEL_BASE_LU_Entry.TABLE_NAME, vals,
                                WHEEL_BASE_LU_Entry.COLUMN_NAME_ID + " = ?", where);
                        break;
                    case INSERT:
                        db.insert(WHEEL_BASE_LU_Entry.TABLE_NAME, null, vals);
                        break;
                    case DELETE:
                        db.delete(WHEEL_BASE_LU_Entry.TABLE_NAME, WHEEL_BASE_LU_Entry.COLUMN_NAME_ID + " = ?",
                                where);
                        break;
                    default:
                    }
                } finally {
                    if (c != null)
                        c.close();
                    ScoutingDBHelper.getInstance().close();
                }
            }
        }
    } catch (JSONException e) {
        // TODO handle error
    }
}

From source file:org.frc836.database.DBSyncService.java

private void processWheelType(JSONArray wheelType) {
    try {// w w w  .j a  va 2s  .  com
        for (int i = 0; i < wheelType.length(); i++) {
            JSONObject row = wheelType.getJSONObject(i);
            Action action = Action.UPDATE;
            if (row.getInt(WHEEL_TYPE_LU_Entry.COLUMN_NAME_INVALID) != 0) {
                action = Action.DELETE;
            }
            ContentValues vals = new ContentValues();
            vals.put(WHEEL_TYPE_LU_Entry.COLUMN_NAME_ID, row.getInt(WHEEL_TYPE_LU_Entry.COLUMN_NAME_ID));
            vals.put(WHEEL_TYPE_LU_Entry.COLUMN_NAME_WHEEL_TYPE_DESC,
                    row.getString(WHEEL_TYPE_LU_Entry.COLUMN_NAME_WHEEL_TYPE_DESC));
            vals.put(WHEEL_TYPE_LU_Entry.COLUMN_NAME_TIMESTAMP, DB.dateParser
                    .format(new Date(row.getLong(WHEEL_TYPE_LU_Entry.COLUMN_NAME_TIMESTAMP) * 1000)));

            // check if this entry exists already
            String[] projection = { WHEEL_TYPE_LU_Entry.COLUMN_NAME_WHEEL_TYPE_DESC };
            String[] where = { vals.getAsString(WHEEL_TYPE_LU_Entry.COLUMN_NAME_ID) };

            synchronized (ScoutingDBHelper.lock) {

                SQLiteDatabase db = ScoutingDBHelper.getInstance().getWritableDatabase();

                Cursor c = db.query(WHEEL_TYPE_LU_Entry.TABLE_NAME, projection, // select
                        WHEEL_TYPE_LU_Entry.COLUMN_NAME_ID + "=?", where, null, // don't
                        // group
                        null, // don't filter
                        null, // don't order
                        "0,1"); // limit to 1
                try {
                    if (!c.moveToFirst()) {
                        if (action == Action.UPDATE)
                            action = Action.INSERT;
                        else if (action == Action.DELETE)
                            action = Action.NOTHING;
                    }

                    switch (action) {
                    case UPDATE:
                        db.update(WHEEL_TYPE_LU_Entry.TABLE_NAME, vals,
                                WHEEL_TYPE_LU_Entry.COLUMN_NAME_ID + " = ?", where);
                        break;
                    case INSERT:
                        db.insert(WHEEL_TYPE_LU_Entry.TABLE_NAME, null, vals);
                        break;
                    case DELETE:
                        db.delete(WHEEL_TYPE_LU_Entry.TABLE_NAME, WHEEL_TYPE_LU_Entry.COLUMN_NAME_ID + " = ?",
                                where);
                        break;
                    default:
                    }
                } finally {
                    if (c != null)
                        c.close();
                    ScoutingDBHelper.getInstance().close();
                }
            }
        }
    } catch (JSONException e) {
        // TODO handle error
    }
}

From source file:org.frc836.database.DBSyncService.java

private void processConfig(JSONArray config) {
    try {//from w ww .j a va  2 s .  com
        for (int i = 0; i < config.length(); i++) {
            JSONObject row = config.getJSONObject(i);
            Action action = Action.UPDATE;
            if (row.getInt(CONFIGURATION_LU_Entry.COLUMN_NAME_INVALID) != 0) {
                action = Action.DELETE;
            }
            ContentValues vals = new ContentValues();
            vals.put(CONFIGURATION_LU_Entry.COLUMN_NAME_ID, row.getInt(CONFIGURATION_LU_Entry.COLUMN_NAME_ID));
            vals.put(CONFIGURATION_LU_Entry.COLUMN_NAME_CONFIGURATION_DESC,
                    row.getString(CONFIGURATION_LU_Entry.COLUMN_NAME_CONFIGURATION_DESC));
            vals.put(CONFIGURATION_LU_Entry.COLUMN_NAME_TIMESTAMP, DB.dateParser
                    .format(new Date(row.getLong(CONFIGURATION_LU_Entry.COLUMN_NAME_TIMESTAMP) * 1000)));

            // check if this entry exists already
            String[] projection = { CONFIGURATION_LU_Entry.COLUMN_NAME_CONFIGURATION_DESC };
            String[] where = { vals.getAsString(CONFIGURATION_LU_Entry.COLUMN_NAME_ID) };
            synchronized (ScoutingDBHelper.lock) {

                SQLiteDatabase db = ScoutingDBHelper.getInstance().getWritableDatabase();

                Cursor c = db.query(CONFIGURATION_LU_Entry.TABLE_NAME, projection, // select
                        CONFIGURATION_LU_Entry.COLUMN_NAME_ID + "=?", where, null, // don't
                        // group
                        null, // don't filter
                        null, // don't order
                        "0,1"); // limit to 1
                try {
                    if (!c.moveToFirst()) {
                        if (action == Action.UPDATE)
                            action = Action.INSERT;
                        else if (action == Action.DELETE)
                            action = Action.NOTHING;
                    }

                    switch (action) {
                    case UPDATE:
                        db.update(CONFIGURATION_LU_Entry.TABLE_NAME, vals,
                                CONFIGURATION_LU_Entry.COLUMN_NAME_ID + " = ?", where);
                        break;
                    case INSERT:
                        db.insert(CONFIGURATION_LU_Entry.TABLE_NAME, null, vals);
                        break;
                    case DELETE:
                        db.delete(CONFIGURATION_LU_Entry.TABLE_NAME,
                                CONFIGURATION_LU_Entry.COLUMN_NAME_ID + " = ?", where);
                        break;
                    default:
                    }
                } finally {
                    if (c != null)
                        c.close();
                    ScoutingDBHelper.getInstance().close();
                }
            }
        }
    } catch (JSONException e) {
        // TODO handle error
    }
}

From source file:org.kontalk.provider.UsersProvider.java

private Uri insertOrUpdateKey(String jid, String fingerprint, ContentValues values, boolean insertOnly) {
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    if (jid == null || fingerprint == null)
        throw new IllegalArgumentException("either JID or fingerprint not provided");

    int rows = 0;

    try {//  ww w.  jav a 2  s  .com
        // try to insert the key with the provided values
        ContentValues insertValues = new ContentValues(values);
        insertValues.put(Keys.JID, jid);
        insertValues.put(Keys.FINGERPRINT, fingerprint);
        // use current timestamp if the caller didn't provide any
        long timestamp = values.containsKey(Keys.TIMESTAMP) ? values.getAsLong(Keys.TIMESTAMP)
                : System.currentTimeMillis();
        insertValues.put(Keys.TIMESTAMP, timestamp);
        db.insertOrThrow(TABLE_KEYS, null, insertValues);
        rows = 1;
    } catch (SQLiteConstraintException e) {
        if (!insertOnly) {
            // we got a duplicated key, update the requested values
            rows = db.update(TABLE_KEYS, values, Keys.JID + "=? AND " + Keys.FINGERPRINT + "=?",
                    new String[] { jid, fingerprint });
        }
    }

    if (rows >= 0)
        return Keys.CONTENT_URI.buildUpon().appendPath(jid).appendPath(fingerprint).build();
    return null;
}

From source file:com.money.manager.ex.database.MmxOpenHelper.java

private void initCategories(SQLiteDatabase database) {
    try {//from w  w w  .  ja v a2 s  .  c o  m
        Cursor countCategories = database.rawQuery("SELECT * FROM CATEGORY_V1", null);
        if (countCategories == null || countCategories.getCount() > 0)
            return;

        int keyCategory = 0;
        String[] categories = new String[] { "1;1", "2;1", "3;1", "4;1", "5;1", "6;1", "7;1", "8;2", "9;2",
                "10;3", "11;3", "12;3", "13;4", "14;4", "15;4", "16;4", "17;5", "18;5", "19;5", "20;6", "21;6",
                "22;6", "23;7", "24;7", "25;7", "26;7", "27;7", "28;8", "29;8", "30;8", "31;8", "32;9", "33;9",
                "34;9", "35;10", "36;10", "37;10", "38;10", "39;13", "40;13", "41;13" };

        for (String item : categories) {
            int subCategoryId = Integer.parseInt(item.substring(0, item.indexOf(";")));
            int categoryId = Integer.parseInt(item.substring(item.indexOf(";") + 1));

            if (categoryId != keyCategory) {
                keyCategory = categoryId;
                int idStringCategory = mContext.getResources().getIdentifier(
                        "category_" + Integer.toString(categoryId), "string", mContext.getPackageName());

                if (idStringCategory > 0) {
                    ContentValues contentValues = new ContentValues();
                    contentValues.put(Category.CATEGID, categoryId);
                    contentValues.put(Category.CATEGNAME, mContext.getString(idStringCategory));

                    // Update existing records, inserted via the db creation script.
                    int updated = database.update(CategoryRepository.tableName, contentValues,
                            Category.CATEGID + "=?", new String[] { Integer.toString(categoryId) });
                    if (updated <= 0) {
                        Timber.w("updating %s for category %s", contentValues.toString(),
                                Integer.toString(categoryId));
                    }
                }
            }

            int idStringSubcategory = mContext.getResources().getIdentifier(
                    "subcategory_" + Integer.toString(subCategoryId), "string", mContext.getPackageName());
            if (idStringSubcategory > 0) {
                ContentValues contentValues = new ContentValues();
                contentValues.put(Subcategory.SUBCATEGID, subCategoryId);
                contentValues.put(Subcategory.CATEGID, categoryId);
                contentValues.put(Subcategory.SUBCATEGNAME, mContext.getString(idStringSubcategory));

                int updated = database.update(SubcategoryRepository.tableName, contentValues,
                        Subcategory.SUBCATEGID + "=?", new String[] { Integer.toString(subCategoryId) });
                if (updated <= 0) {
                    Timber.w("update failed, %s for subcategory %s", contentValues.toString(),
                            Integer.toString(subCategoryId));
                }
            }
        }

        countCategories.close();
    } catch (Exception e) {
        Timber.e(e, "init database, categories");
    }
}