Example usage for android.content ContentResolver update

List of usage examples for android.content ContentResolver update

Introduction

In this page you can find the example usage for android.content ContentResolver update.

Prototype

public final int update(@RequiresPermission.Write @NonNull Uri uri, @Nullable ContentValues values,
        @Nullable String where, @Nullable String[] selectionArgs) 

Source Link

Document

Update row(s) in a content URI.

Usage

From source file:org.mariotaku.twidere.loader.support.ParcelableUserLoader.java

@Override
public SingleResponse<ParcelableUser> loadInBackground() {
    final Context context = getContext();
    final ContentResolver resolver = context.getContentResolver();
    if (!mOmitIntentExtra && mExtras != null) {
        final ParcelableUser user = mExtras.getParcelable(EXTRA_USER);
        if (user != null) {
            final ContentValues values = ParcelableUser.makeCachedUserContentValues(user);
            resolver.insert(CachedUsers.CONTENT_URI, values);
            return SingleResponse.getInstance(user);
        }//from   w  w  w . j ava  2 s  .  c  o m
    }
    final Twitter twitter = TwitterAPIFactory.getTwitterInstance(context, mAccountId, true);
    if (twitter == null)
        return SingleResponse.getInstance();
    if (mLoadFromCache) {
        final Expression where;
        final String[] whereArgs;
        if (mUserId > 0) {
            where = Expression.equals(CachedUsers.USER_ID, mUserId);
            whereArgs = null;
        } else {
            where = Expression.equalsArgs(CachedUsers.SCREEN_NAME);
            whereArgs = new String[] { mScreenName };
        }
        final Cursor cur = resolver.query(CachedUsers.CONTENT_URI, CachedUsers.COLUMNS, where.getSQL(),
                whereArgs, null);
        final int count = cur.getCount();
        try {
            if (count > 0) {
                final CachedIndices indices = new CachedIndices(cur);
                cur.moveToFirst();
                return SingleResponse.getInstance(new ParcelableUser(cur, indices, mAccountId));
            }
        } finally {
            cur.close();
        }
    }
    try {
        final User user = TwitterWrapper.tryShowUser(twitter, mUserId, mScreenName);
        final ContentValues cachedUserValues = createCachedUser(user);
        final long userId = user.getId();
        resolver.insert(CachedUsers.CONTENT_URI, cachedUserValues);
        final ParcelableUser result = new ParcelableUser(user, mAccountId);
        if (isMyAccount(context, userId)) {
            final ContentValues accountValues = new ContentValues();
            accountValues.put(Accounts.NAME, result.name);
            accountValues.put(Accounts.SCREEN_NAME, result.screen_name);
            accountValues.put(Accounts.PROFILE_IMAGE_URL, result.profile_image_url);
            accountValues.put(Accounts.PROFILE_BANNER_URL, result.profile_banner_url);
            final String accountWhere = Expression.equals(Accounts.ACCOUNT_ID, userId).getSQL();
            resolver.update(Accounts.CONTENT_URI, accountValues, accountWhere, null);
        }
        return SingleResponse.getInstance(result);
    } catch (final TwitterException e) {
        Log.w(LOGTAG, e);
        return SingleResponse.getInstance(e);
    }
}

From source file:com.akop.bach.parser.XboxLiveParser.java

private void parseUpdateProfile(XboxLiveAccount account, String motto, String name, String location, String bio)
        throws ParserException, IOException {
    long started = System.currentTimeMillis();

    String url = String.format(URL_EDIT_PROFILE, mLocale);
    String page = getResponse(url);

    if (App.getConfig().logToConsole())
        started = displayTimeTaken("Profile load", started);

    List<NameValuePair> inputs = new ArrayList<NameValuePair>(10);
    getInputs(page, inputs, null);//from  w ww  .  jav a 2s  . c o  m

    setValue(inputs, "Motto", motto);
    setValue(inputs, "RealName", name);
    setValue(inputs, "Location", location);
    setValue(inputs, "Bio", bio);

    try {
        submitRequest(url, inputs);

        // This shouldn't happen - user was not redirected
        throw new ParserException(mContext, R.string.error_updating_profile);
    } catch (ClientProtocolException e) {
        // This is normal; user is redirected to his overview page
    }

    if (App.getConfig().logToConsole())
        started = displayTimeTaken("Profile update", started);

    // Update local information

    ContentResolver cr = mContext.getContentResolver();
    ContentValues cv = new ContentValues(10);

    cv.put(Profiles.MOTTO, motto);
    cv.put(Profiles.NAME, name);
    cv.put(Profiles.LOCATION, location);
    cv.put(Profiles.BIO, bio);

    Uri uri = ContentUris.withAppendedId(Profiles.CONTENT_URI, account.getId());

    cr.update(uri, cv, null, null);

    account.setLastSummaryUpdate(System.currentTimeMillis());
    account.save(Preferences.get(mContext));

    cr.notifyChange(uri, null);
}

From source file:com.hhunj.hhudata.SearchBookContentsActivity.java

public void updatedb(List<SearchBookContentsResult> items) {
    int max_alarm_time_span = 60;
    ContentResolver resolver = getApplicationContext().getContentResolver();

    ContentValues values = new ContentValues();

    for (int i = 0; i < items.size(); i++) {

        SearchBookContentsResult res = items.get(i);
        long stationid = Long.parseLong(res.getPageNumber());

        values.put(NotePad.Notes.TITLE, res.getName());
        values.put(NotePad.Notes.NOTE, "");

        values.put(NotePad.Notes.LONGITUTE, 108.0);
        values.put(NotePad.Notes.LATITUDE, 32.0);
        values.put(NotePad.Notes.SPEED, 55);
        values.put(NotePad.Notes.ALTITUDE, 55);

        values.put(NotePad.Notes.CREATEDDATE, res.getRectime().getTime());

        values.put(NotePad.Notes._ID, stationid);//id

        Uri urlNote = NotePad.Notes.CONTENT_URI;

        Uri myUri = ContentUris.withAppendedId(NotePad.Notes.CONTENT_URI, stationid);

        Cursor cur = resolver.query(myUri, NotePad.Notes.PROJECTION, null, null, null);

        if (cur != null && cur.moveToFirst()) {
            try {
                long id = cur.getLong(NotePad.Notes._ID_COLUMN);
                Date oldtime = new Date(cur.getLong(cur.getColumnIndex(NotePad.Notes.CREATEDDATE)));
                boolean oldalarm = (cur.getInt(NotePad.Notes.ALARM_COLUMN) == 0) ? false : true;

                long dif = (res.getRectime().getTime() - oldtime.getTime()) / (60 * 1000);

                dif = ((new Date()).getTime() - oldtime.getTime()) / (60 * 1000);

                if (dif > max_alarm_time_span) {
                    //...
                    if (oldalarm == false) {
                        Log.w(TAG, "over time err--------");
                        String phoneNumber = "13338620269";
                        String message = "over time err--------";
                        sendSMS(phoneNumber, message);
                        values.put(NotePad.Notes.ALARM, true);
                    }//  w w w  . jav a2s  .  c  o  m

                } else {
                    values.put(NotePad.Notes.ALARM, false);
                }

            } catch (Exception e) {
                int aa = 0;

            }

            int count = resolver.update(myUri, values, null, null);
            //  resolver.update( myUri, values, NotePad.Notes._ID + " = " +res.getPageNumber(), null);
            if (count == 0) {

            }
        } else {
            try {
                myUri = resolver.insert(urlNote, values);
            } catch (IllegalArgumentException e) {
                throw e;
            }
        }
    }

}

From source file:com.akop.bach.parser.PsnUsParser.java

protected void parseFriends(PsnAccount account) throws ParserException, IOException {
    synchronized (PsnUsParser.class) {
        String url = String.format(URL_FRIENDS, Math.random());
        HttpUriRequest request = new HttpGet(url);

        request.addHeader("Referer", "http://us.playstation.com/myfriends/");
        request.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

        String page = getResponse(request, null);

        ContentResolver cr = mContext.getContentResolver();
        final long accountId = account.getId();
        ContentValues cv;/*  w w w. ja  va 2  s  . co m*/
        List<ContentValues> newCvs = new ArrayList<ContentValues>(100);

        int rowsInserted = 0;
        int rowsUpdated = 0;
        int rowsDeleted = 0;

        long updated = System.currentTimeMillis();
        long started = updated;
        Matcher gameMatcher = PATTERN_FRIENDS.matcher(page);

        while (gameMatcher.find()) {
            String friendGt = htmlDecode(gameMatcher.group(1));
            GamerProfileInfo gpi;

            try {
                gpi = parseGamerProfile(account, friendGt);
            } catch (IOException e) {
                if (App.getConfig().logToConsole())
                    App.logv("Friend " + friendGt + " threw an IOException");

                // Update the DeleteMarker, so that the GT is not removed

                cv = new ContentValues(15);
                cv.put(Friends.DELETE_MARKER, updated);

                cr.update(Friends.CONTENT_URI, cv,
                        Friends.ACCOUNT_ID + "=" + account.getId() + " AND " + Friends.ONLINE_ID + "=?",
                        new String[] { friendGt });

                continue;
            } catch (Exception e) {
                // The rest of the exceptions assume problems with Friend
                // and potentially remove him/her

                if (App.getConfig().logToConsole()) {
                    App.logv("Friend " + friendGt + " threw an Exception");
                    e.printStackTrace();
                }

                continue;
            }

            Cursor c = cr.query(Friends.CONTENT_URI, FRIEND_ID_PROJECTION,
                    Friends.ACCOUNT_ID + "=" + account.getId() + " AND " + Friends.ONLINE_ID + "=?",
                    new String[] { friendGt }, null);

            long friendId = -1;

            if (c != null) {
                try {
                    if (c.moveToFirst())
                        friendId = c.getLong(0);
                } finally {
                    c.close();
                }
            }

            cv = new ContentValues(15);

            cv.put(Friends.ONLINE_ID, gpi.OnlineId);
            cv.put(Friends.ICON_URL, gpi.AvatarUrl);
            cv.put(Friends.LEVEL, gpi.Level);
            cv.put(Friends.PROGRESS, gpi.Progress);
            cv.put(Friends.ONLINE_STATUS, gpi.OnlineStatus);
            cv.put(Friends.TROPHIES_PLATINUM, gpi.PlatinumTrophies);
            cv.put(Friends.TROPHIES_GOLD, gpi.GoldTrophies);
            cv.put(Friends.TROPHIES_SILVER, gpi.SilverTrophies);
            cv.put(Friends.TROPHIES_BRONZE, gpi.BronzeTrophies);
            cv.put(Friends.PLAYING, gpi.Playing);
            cv.put(Friends.DELETE_MARKER, updated);
            cv.put(Friends.LAST_UPDATED, updated);

            if (friendId < 0) {
                // New
                cv.put(Friends.ACCOUNT_ID, accountId);

                newCvs.add(cv);
            } else {
                cr.update(ContentUris.withAppendedId(Friends.CONTENT_URI, friendId), cv, null, null);

                rowsUpdated++;
            }
        }

        // Remove friends
        rowsDeleted = cr.delete(Friends.CONTENT_URI,
                Friends.ACCOUNT_ID + "=" + accountId + " AND " + Friends.DELETE_MARKER + "!=" + updated, null);

        if (newCvs.size() > 0) {
            ContentValues[] cvs = new ContentValues[newCvs.size()];
            newCvs.toArray(cvs);

            rowsInserted = cr.bulkInsert(Friends.CONTENT_URI, cvs);
        }

        account.refresh(Preferences.get(mContext));
        account.setLastFriendUpdate(System.currentTimeMillis());
        account.save(Preferences.get(mContext));

        cr.notifyChange(Friends.CONTENT_URI, null);

        if (App.getConfig().logToConsole())
            started = displayTimeTaken("Friend page processing [I:" + rowsInserted + ";U:" + rowsUpdated + ";D:"
                    + rowsDeleted + "]", started);
    }
}

From source file:com.ichi2.anki.tests.ContentProviderTest.java

/**
 * Check that inserting a new model works as expected
 *///from  w  w w  .  jav  a  2  s  .co  m
public void testInsertAndUpdateModel() throws Exception {
    final ContentResolver cr = getContext().getContentResolver();
    ContentValues cv = new ContentValues();
    // Insert a new model
    cv.put(FlashCardsContract.Model.NAME, TEST_MODEL_NAME);
    cv.put(FlashCardsContract.Model.FIELD_NAMES, Utils.joinFields(TEST_MODEL_FIELDS));
    cv.put(FlashCardsContract.Model.NUM_CARDS, TEST_MODEL_CARDS.length);
    cv.put(FlashCardsContract.Model.CSS, TEST_MODEL_CSS);
    Uri modelUri = cr.insert(FlashCardsContract.Model.CONTENT_URI, cv);
    assertNotNull("Check inserted model isn't null", modelUri);
    long mid = Long.parseLong(modelUri.getLastPathSegment());
    final Collection col = CollectionHelper.getInstance().getCol(getContext());
    try {
        JSONObject model = col.getModels().get(mid);
        assertEquals("Check model name", TEST_MODEL_NAME, model.getString("name"));
        assertEquals("Check css", TEST_MODEL_CSS, model.getString("css"));
        assertEquals("Check templates length", TEST_MODEL_CARDS.length, model.getJSONArray("tmpls").length());
        assertEquals("Check field length", TEST_MODEL_FIELDS.length, model.getJSONArray("flds").length());
        JSONArray flds = model.getJSONArray("flds");
        for (int i = 0; i < flds.length(); i++) {
            assertEquals("Check name of fields", flds.getJSONObject(i).getString("name"), TEST_MODEL_FIELDS[i]);
        }
        // Update each of the templates in the model
        for (int i = 0; i < TEST_MODEL_CARDS.length; i++) {
            cv = new ContentValues();
            cv.put(FlashCardsContract.CardTemplate.NAME, TEST_MODEL_CARDS[i]);
            cv.put(FlashCardsContract.CardTemplate.QUESTION_FORMAT, TEST_MODEL_QFMT[i]);
            cv.put(FlashCardsContract.CardTemplate.ANSWER_FORMAT, TEST_MODEL_AFMT[i]);
            cv.put(FlashCardsContract.CardTemplate.BROWSER_QUESTION_FORMAT, TEST_MODEL_QFMT[i]);
            cv.put(FlashCardsContract.CardTemplate.BROWSER_ANSWER_FORMAT, TEST_MODEL_AFMT[i]);
            Uri tmplUri = Uri.withAppendedPath(Uri.withAppendedPath(modelUri, "templates"),
                    Integer.toString(i));
            assertTrue("Update rows", cr.update(tmplUri, cv, null, null) > 0);
            JSONObject template = col.getModels().get(mid).getJSONArray("tmpls").getJSONObject(i);
            assertEquals("Check template name", TEST_MODEL_CARDS[i], template.getString("name"));
            assertEquals("Check qfmt", TEST_MODEL_QFMT[i], template.getString("qfmt"));
            assertEquals("Check afmt", TEST_MODEL_AFMT[i], template.getString("afmt"));
            assertEquals("Check bqfmt", TEST_MODEL_QFMT[i], template.getString("bqfmt"));
            assertEquals("Check bafmt", TEST_MODEL_AFMT[i], template.getString("bafmt"));
        }
    } finally {
        // Delete the model (this will force a full-sync)
        try {
            col.modSchema(false);
            col.getModels().rem(col.getModels().get(mid));
        } catch (ConfirmModSchemaException e) {
            // This will never happen
            throw new IllegalStateException("Unexpected ConfirmModSchemaException trying to remove model");
        }
    }
}

From source file:com.android.exchange.ExchangeService.java

/**
 * Return a list of all Accounts in EmailProvider.  Because the result of this call may be used
 * in account reconciliation, an exception is thrown if the result cannot be guaranteed accurate
 * @param context the caller's context/*from www .  java 2 s  .  co  m*/
 * @param accounts a list that Accounts will be added into
 * @return the list of Accounts
 * @throws ProviderUnavailableException if the list of Accounts cannot be guaranteed valid
 */
private static AccountList collectEasAccounts(Context context, AccountList accounts) {
    ContentResolver resolver = context.getContentResolver();
    Cursor c = resolver.query(Account.CONTENT_URI, Account.CONTENT_PROJECTION, null, null, null);
    // We must throw here; callers might use the information we provide for reconciliation, etc.
    if (c == null)
        throw new ProviderUnavailableException();
    try {
        ContentValues cv = new ContentValues();
        while (c.moveToNext()) {
            long hostAuthId = c.getLong(Account.CONTENT_HOST_AUTH_KEY_RECV_COLUMN);
            if (hostAuthId > 0) {
                HostAuth ha = HostAuth.restoreHostAuthWithId(context, hostAuthId);
                if (ha != null && ha.mProtocol.equals("eas")) {
                    Account account = new Account();
                    account.restore(c);
                    // Cache the HostAuth
                    account.mHostAuthRecv = ha;
                    accounts.add(account);
                    // Fixup flags for inbox (should accept moved mail)
                    Mailbox inbox = Mailbox.restoreMailboxOfType(context, account.mId, Mailbox.TYPE_INBOX);
                    if (inbox != null && ((inbox.mFlags & Mailbox.FLAG_ACCEPTS_MOVED_MAIL) == 0)) {
                        cv.put(MailboxColumns.FLAGS, inbox.mFlags | Mailbox.FLAG_ACCEPTS_MOVED_MAIL);
                        resolver.update(ContentUris.withAppendedId(Mailbox.CONTENT_URI, inbox.mId), cv, null,
                                null);
                    }
                }
            }
        }
    } finally {
        c.close();
    }
    return accounts;
}

From source file:com.akop.bach.parser.XboxLiveParser.java

private void parseAccountSummary(XboxLiveAccount account) throws ParserException, IOException {
    ContentValues cv = parseSummaryData(account);
    ContentResolver cr = mContext.getContentResolver();

    long accountId = account.getId();
    boolean newRecord = true;

    long started = System.currentTimeMillis();
    Cursor c = cr.query(Profiles.CONTENT_URI, new String[] { Profiles._ID },
            Profiles.ACCOUNT_ID + "=" + accountId, null, null);

    if (c != null) {
        if (c.moveToFirst())
            newRecord = false;/*from  www .  ja  v  a2s. co m*/
        c.close();
    }

    if (newRecord) {
        cv.put(Profiles.ACCOUNT_ID, account.getId());
        cv.put(Profiles.UUID, account.getUuid());

        cr.insert(Profiles.CONTENT_URI, cv);
    } else {
        cr.update(Profiles.CONTENT_URI, cv, Profiles.ACCOUNT_ID + "=" + accountId, null);
    }

    cr.notifyChange(Profiles.CONTENT_URI, null);

    if (App.getConfig().logToConsole())
        displayTimeTaken("Summary update", started);

    account.refresh(Preferences.get(mContext));
    account.setGamertag(cv.getAsString(Profiles.GAMERTAG));
    account.setIconUrl(cv.getAsString(Profiles.ICON_URL));
    account.setGoldStatus(cv.getAsBoolean(Profiles.IS_GOLD));
    account.setLastSummaryUpdate(System.currentTimeMillis());
    account.save(Preferences.get(mContext));
}

From source file:com.akop.bach.parser.XboxLiveParser.java

private void parseRefreshBeaconData(XboxLiveAccount account, String token) throws ParserException, IOException {
    long started = System.currentTimeMillis();

    ContentResolver cr = mContext.getContentResolver();
    String url = String.format(URL_JSON_BEACONS, mLocale);

    List<NameValuePair> inputs = new ArrayList<NameValuePair>(3);
    addValue(inputs, "__RequestVerificationToken", token);

    JSONArray activities = getXboxJsonArray(url, inputs);

    if (App.getConfig().logToConsole())
        started = displayTimeTaken("Beacon page fetch", started);

    if (activities != null) {
        // Unset all current beacons

        ContentValues cv = new ContentValues();
        cv.put(Games.BEACON_SET, 0);/*from   ww  w. j av  a2  s . c  o  m*/
        cv.put(Games.BEACON_TEXT, (String) null);

        cr.update(Games.CONTENT_URI, cv, Games.ACCOUNT_ID + "=" + account.getId(), null);

        for (int i = 0, n = activities.length(); i < n; i++) {
            JSONObject activity = activities.optJSONObject(i);
            String titleId;
            JSONObject beacon;

            if (activity == null || (titleId = activity.optString("titleId")) == null
                    || (beacon = activity.optJSONObject("beacon")) == null) {
                continue;
            }

            Long gameId = Games.getId(mContext, account, titleId);
            if (gameId == null)
                continue;

            cv = new ContentValues();
            cv.put(Games.BEACON_SET, 1);
            cv.put(Games.BEACON_TEXT, beacon.optString("text"));

            cr.update(Games.CONTENT_URI, cv, Games._ID + "=" + gameId, null);
        }

        cr.notifyChange(Games.CONTENT_URI, null);
    }

    if (App.getConfig().logToConsole())
        started = displayTimeTaken("Beacon updates", started);
}

From source file:com.akop.bach.parser.PsnUsParser.java

protected void parseFriendSummary(PsnAccount account, String friendOnlineId)
        throws ParserException, IOException {
    long updated = System.currentTimeMillis();
    long started = updated;

    GamerProfileInfo gpi = parseGamerProfile(account, friendOnlineId);

    ContentResolver cr = mContext.getContentResolver();
    Cursor c = cr.query(Friends.CONTENT_URI, FRIEND_ID_PROJECTION,
            Friends.ACCOUNT_ID + "=" + account.getId() + " AND " + Friends.ONLINE_ID + "=?",
            new String[] { friendOnlineId }, null);

    long friendId = -1;

    try {//from   w w  w .  j  a  v  a2s.c o m
        if (c != null && c.moveToFirst())
            friendId = c.getLong(0);
    } finally {
        if (c != null)
            c.close();
    }

    ContentValues cv = new ContentValues(15);

    cv.put(Friends.ONLINE_ID, gpi.OnlineId);
    cv.put(Friends.ICON_URL, gpi.AvatarUrl);
    cv.put(Friends.LEVEL, gpi.Level);
    cv.put(Friends.PROGRESS, gpi.Progress);
    cv.put(Friends.ONLINE_STATUS, gpi.OnlineStatus);
    cv.put(Friends.TROPHIES_PLATINUM, gpi.PlatinumTrophies);
    cv.put(Friends.TROPHIES_GOLD, gpi.GoldTrophies);
    cv.put(Friends.TROPHIES_SILVER, gpi.SilverTrophies);
    cv.put(Friends.TROPHIES_BRONZE, gpi.BronzeTrophies);
    cv.put(Friends.PLAYING, gpi.Playing);
    cv.put(Friends.LAST_UPDATED, updated);

    if (friendId < 0) {
        // New
        cv.put(Friends.ACCOUNT_ID, account.getId());
        cr.insert(Friends.CONTENT_URI, cv);
    } else {
        cr.update(ContentUris.withAppendedId(Friends.CONTENT_URI, friendId), cv, null, null);
    }

    if (App.getConfig().logToConsole())
        started = displayTimeTaken("Friend page processing", started);

    cr.notifyChange(ContentUris.withAppendedId(Friends.CONTENT_URI, friendId), null);
}

From source file:com.akop.bach.parser.PsnEuParser.java

@SuppressLint("DefaultLocale")
@Override//from  w w  w .j  a v a 2s.  c  om
protected void parseGames(PsnAccount account) throws ParserException, IOException {
    long started = System.currentTimeMillis();
    boolean keepGoing = true;
    List<ContentValues> cvList = new ArrayList<ContentValues>();

    for (int startIndex = 0; keepGoing; startIndex += 16) {
        String url = String.format(URL_GAMES, startIndex);
        String page = getResponse(url);

        keepGoing = parseGamePage(startIndex, page, cvList);
    }

    final long accountId = account.getId();
    ContentResolver cr = mContext.getContentResolver();
    String[] queryParams = new String[1];
    Cursor c;
    long updated = System.currentTimeMillis();
    List<ContentValues> newCvs = new ArrayList<ContentValues>(100);

    // Check to see if we already have a record of this game
    for (ContentValues cv : cvList) {
        queryParams[0] = cv.getAsString(Games.UID);
        c = cr.query(Games.CONTENT_URI, GAMES_PROJECTION,
                Games.ACCOUNT_ID + "=" + accountId + " AND " + Games.UID + "=?", queryParams, null);

        try {
            if (c == null || !c.moveToFirst()) // New game
            {
                cv.put(Games.ACCOUNT_ID, accountId);
                cv.put(Games.TROPHIES_DIRTY, 1);
                cv.put(Games.LAST_UPDATED, updated);

                newCvs.add(cv);
            } else // Existing game
            {
                boolean isDirty = false;
                long gameId = c.getLong(COLUMN_GAME_ID);

                if (c.getInt(COLUMN_GAME_PROGRESS) != cv.getAsInteger(Games.PROGRESS))
                    isDirty = true;
                if (c.getInt(COLUMN_GAME_BRONZE) != cv.getAsInteger(Games.UNLOCKED_BRONZE))
                    isDirty = true;
                if (c.getInt(COLUMN_GAME_SILVER) != cv.getAsInteger(Games.UNLOCKED_SILVER))
                    isDirty = true;
                if (c.getInt(COLUMN_GAME_GOLD) != cv.getAsInteger(Games.UNLOCKED_GOLD))
                    isDirty = true;
                if (c.getInt(COLUMN_GAME_PLATINUM) != cv.getAsInteger(Games.UNLOCKED_PLATINUM))
                    isDirty = true;

                if (isDirty)
                    cv.put(Games.TROPHIES_DIRTY, 1);

                cv.put(Games.LAST_UPDATED, updated);

                cr.update(Games.CONTENT_URI, cv, Games._ID + "=" + gameId, null);
            }
        } finally {
            if (c != null)
                c.close();
        }
    }

    if (App.getConfig().logToConsole())
        started = displayTimeTaken("Game page processing", started);

    if (newCvs.size() > 0) {
        ContentValues[] cvs = new ContentValues[newCvs.size()];
        newCvs.toArray(cvs);

        cr.bulkInsert(Games.CONTENT_URI, cvs);

        if (App.getConfig().logToConsole())
            displayTimeTaken("Game page insertion", started);
    }

    account.refresh(Preferences.get(mContext));
    account.setLastGameUpdate(System.currentTimeMillis());
    account.save(Preferences.get(mContext));

    cr.notifyChange(Games.CONTENT_URI, null);
}