List of usage examples for android.database.sqlite SQLiteDatabase update
public int update(String table, ContentValues values, String whereClause, String[] whereArgs)
From source file:DictionaryDatabase.java
public int updateRecord(long id, String word, String definition) { SQLiteDatabase db = getWritableDatabase(); ContentValues values = new ContentValues(); values.put("_id", id); values.put(FIELD_WORD, word);//from ww w. j a v a 2 s .c om values.put(FIELD_DEFINITION, definition); return db.update(TABLE_DICTIONARY, values, "_id = ?", new String[] { String.valueOf(id) }); }
From source file:com.itime.team.itime.services.ITimeGcmListenerService.java
private void updateUserTable(Context context) { UserTableHelper dbHelper = new UserTableHelper(context, "userbase1"); SQLiteDatabase db = dbHelper.getReadableDatabase(); ContentValues values = new ContentValues(); values.put("remember", false); db.update("itime_user", values, "id=?", new String[] { "1" }); dbHelper.close();/* w ww . j a v a 2 s. c om*/ db.close(); }
From source file:com.cuddlesoft.nori.database.APISettingsDatabase.java
/** * Update an existing {@link SearchClient.Settings} object in the database. * * @param id Row ID.//from w ww .j a v a 2 s. co m * @param settings Settings object with data to update. * @return Number of rows affected. */ public int update(long id, SearchClient.Settings settings) { // Update data in the database. SQLiteDatabase db = getWritableDatabase(); final int rows = db.update(TABLE_NAME, searchClientSettingsToContentValues(settings), COLUMN_ID + " = ?", new String[] { Long.toString(id) }); db.close(); sendUpdateNotification(); return rows; }
From source file:com.manning.androidhacks.hack043.provider.BatchNumbersContentProvider.java
@Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { SQLiteDatabase db = dbHelper.getWritableDatabase(); int count = 0; switch (sUriMatcher.match(uri)) { case ITEM:/*from ww w . j av a2 s .c o m*/ count = db.update(TABLE_NAME, values, selection, selectionArgs); break; case ITEM_ID: count = db.update(TABLE_NAME, values, COLUMN_ID + "=" + uri.getPathSegments().get(1) + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ")" : ""), selectionArgs); break; default: throw new RuntimeException("Unknown URI " + uri); } getContext().getContentResolver().notifyChange(uri, null); return count; }
From source file:com.manning.androidhacks.hack023.provider.TodoContentProvider.java
@Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { SQLiteDatabase db = dbHelper.getWritableDatabase(); int count = 0; switch (sUriMatcher.match(uri)) { case TODO:/*from w w w . jav a 2s . com*/ count = db.update(TODO_TABLE_NAME, values, selection, selectionArgs); break; case TODO_ID: count = db.update(TODO_TABLE_NAME, values, COLUMN_ID + "=" + uri.getPathSegments().get(1) + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ")" : ""), selectionArgs); break; default: throw new RuntimeException("Unknown URI " + uri); } getContext().getContentResolver().notifyChange(uri, null); return count; }
From source file:com.dm.material.dashboard.candybar.databases.Database.java
public void setWallpaperAddedOn(String url, String date) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_ADDED_ON, date);// w ww. java 2 s. c o m db.update(TABLE_WALLPAPERS, values, KEY_URL + " = ?", new String[] { url }); db.close(); }
From source file:com.boardgamegeek.util.SelectionBuilder.java
/** * Execute update using the current internal state as {@code WHERE} clause. *//* w ww.j a v a2s . c o m*/ public int update(SQLiteDatabase db, ContentValues values) { assertTable(); Timber.v("UPDATE: " + this); int count = db.update(mTable, values, getSelection(), getSelectionArgs()); Timber.v("updated " + count + " rows"); return count; }
From source file:com.appsimobile.appsii.module.apps.AppsProvider.java
@Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { SqlArguments args = new SqlArguments(uri, selection, selectionArgs); SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int count = db.update(args.table, values, args.where, args.args); if (count > 0) sendNotify(uri);/*from w w w . j a va 2 s.c o m*/ return count; }
From source file:com.citrus.sdk.database.DBHandler.java
public int setDefaultOption(String optionName) { String whereValues[] = new String[] { optionName }; SQLiteDatabase db = this.getWritableDatabase(); ContentValues newValues = new ContentValues(); if (!TextUtils.isEmpty(optionName)) { try {//from w w w . j av a2s . co m newValues.put(DEFAULT_OPTION, 1); return db.update(PAYOPTION_TABLE, newValues, NAME + "=?", whereValues); } catch (Exception e) { db.close(); return 0; } } else { try { newValues.put(DEFAULT_OPTION, 0); return db.update(PAYOPTION_TABLE, newValues, null, null); } catch (Exception e) { db.close(); return 0; } } }
From source file:syncthing.android.settings.AppSettings.java
public void setDefaultCredentials(Credentials creds) { SQLiteDatabase _db = db.getWritableDatabase(); try {//from w w w .j a v a 2 s. c o m _db.beginTransaction(); ContentValues cv = new ContentValues(); cv.put(CredentialsDB.SCHEMA.DEFAULT, 0); //first unset default for everyone _db.update(CredentialsDB.SCHEMA.TABLE, cv, null, null); cv.put(CredentialsDB.SCHEMA.DEFAULT, 1); String[] sel = new String[] { creds.id }; //set default for specified device _db.update(CredentialsDB.SCHEMA.TABLE, cv, credentialsDeviceIdSel, sel); _db.setTransactionSuccessful(); } finally { _db.endTransaction(); } }