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:com.ksk.droidbatterybooster.provider.PowerSchedule.java

public static boolean updateSchedule(ContentResolver contentResolver, PowerSchedule schedule) {
    if (schedule.id == OptimalMode.INVALID_ID)
        return false;
    ContentValues values = createContentValues(schedule);
    long rowsUpdated = contentResolver.update(getUri(schedule.id), values, null, null);
    return rowsUpdated == 1;
}

From source file:edu.mit.mobile.android.livingpostcards.data.Card.java

public static boolean setCollaborative(ContentResolver cr, Uri card, boolean collaborative) {
    final ContentValues cv = new ContentValues();

    cv.put(Card.COL_PRIVACY, collaborative ? Card.PRIVACY_PUBLIC : Card.PRIVACY_PROTECTED);
    final int count = cr.update(card, cv, null, null);

    return count >= 1;
}

From source file:com.silentcorp.autotracker.db.VehicleDB.java

/**
 * Update existing vehicle/*w  w w  .  j a va2s  .co m*/
 * 
 * @param contentResolver
 * @param vehicle
 * @throws SQLException
 */
public static void updateVehicle(Context context, VehicleBean vehicle) {
    ContentValues values = getAsContentValues(vehicle);

    Uri uri = Uri.parse(DBContentProvider.VEHICLES_URI + "/" + vehicle.getId());
    ContentResolver contentResolver = context.getContentResolver();
    contentResolver.update(uri, values, null, null);
}

From source file:com.ksk.droidbatterybooster.provider.OptimalMode.java

public static boolean updateMode(ContentResolver contentResolver, OptimalMode mode) {
    if (mode.id == OptimalMode.INVALID_ID)
        return false;
    ContentValues values = createContentValues(mode);
    long rowsUpdated = contentResolver.update(getContentUriForId(mode.id), values, null, null);
    return rowsUpdated == 1;
}

From source file:com.ksk.droidbatterybooster.provider.PowerSchedule.java

public static void enableSchedule(final ContentResolver contentResolver, final long id, boolean enabled) {
    PowerSchedule schedule = getSchedule(contentResolver, id);
    if (schedule == null) {
        return;/*from   w  ww .ja va 2 s .c o  m*/
    }
    ContentValues values = new ContentValues(2);
    values.put(ENABLED, enabled ? 1 : 0);
    contentResolver.update(getUri(id), values, null, null);
}

From source file:com.nbos.phonebook.sync.platform.ContactManager.java

public static void resetDirtyGroups(Context ctx) {
    ContentResolver cr = ctx.getContentResolver();
    ContentValues values = new ContentValues();
    values.put(ContactsContract.Groups.DIRTY, "0");
    int num = cr.update(ContactsContract.Groups.CONTENT_URI, values, null, null);
    Log.i(tag, "Updated " + num + " groups to dirty = 0");
    num = cr.delete(SyncManager.addCallerIsSyncAdapterParameter(Groups.CONTENT_URI),
            Groups.DELETED + " = 1 " + " and " + Groups.ACCOUNT_TYPE + " = ? ",
            new String[] { Constants.ACCOUNT_TYPE });
    Log.i(tag, "Deleted " + num + " groups");
}

From source file:saphion.batterycaster.providers.Alarm.java

public static boolean updateAlarm(ContentResolver contentResolver, Alarm alarm) {
    if (alarm.id == Alarm.INVALID_ID)
        return false;
    ContentValues values = createContentValues(alarm);
    long rowsUpdated = contentResolver.update(getUri(alarm.id), values, null, null);
    return rowsUpdated == 1;
}

From source file:com.nbos.phonebook.sync.platform.ContactManager.java

public static void setDirtyContacts(Context mContext) { // for testing
    ContentResolver cr = mContext.getContentResolver();
    Uri uri = ContactsContract.RawContacts.CONTENT_URI;
    ContentValues values = new ContentValues();
    values.put(ContactsContract.RawContacts.DIRTY, 1);
    int num = cr.update(uri, values, null, null);
    Log.i("ContactManager", "Resetting " + num + " dirty on contacts");
}

From source file:com.nbos.phonebook.sync.platform.ContactManager.java

public static void updateBook(JSONObject book, Context context) throws JSONException {
    int sourceId = book.getInt("sourceId"), groupId = book.getInt("groupId");
    Log.i(tag, "updateBook, sourceId: " + sourceId + ", contactId: " + groupId);
    ContentResolver cr = context.getContentResolver();
    Uri uri = ContactsContract.Groups.CONTENT_URI;
    ContentValues values = new ContentValues();
    values.put(ContactsContract.Groups.SOURCE_ID, sourceId);
    int rows = cr.update(uri, values, ContactsContract.Groups._ID + " = " + groupId, null);
    Log.i(tag, rows + " rows updated");
}

From source file:com.nbos.phonebook.sync.platform.ContactManager.java

public static void updateGroup(JSONObject group, Context context) throws JSONException {
    int sourceId = group.getInt("sourceId"), groupId = group.getInt("groupId");
    Log.i(tag, "updateGroup, sourceId: " + sourceId + ", groupId: " + groupId);
    ContentResolver cr = context.getContentResolver();
    Uri uri = ContactsContract.Groups.CONTENT_URI;
    ContentValues values = new ContentValues();
    values.put(ContactsContract.Groups.SOURCE_ID, sourceId);
    int rows = cr.update(uri, values, ContactsContract.Groups._ID + " = " + groupId, null);
    Log.i(tag, "updated " + rows + " rows to sourceId: " + sourceId);
}