Refine search
@Override public void updateConnectionCount(int id, int count) { ContentValues values = new ContentValues(); values.put(FileDownloadModel.CONNECTION_COUNT, count); db.update(TABLE_NAME, values, FileDownloadModel.ID + " = ? ", new String[]{Integer.toString(id)}); }
@Override public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException { ContentValues cv = new ContentValues(); cv.put("deleted", 1); cv.put("empty", 1); cv.putNull("subject"); cv.putNull("sender_list"); cv.putNull("date"); cv.putNull("to_list"); cv.putNull("cc_list"); cv.putNull("bcc_list"); cv.putNull("preview"); cv.putNull("reply_to_list"); cv.putNull("message_part_id"); db.update("messages", cv, "id = ?", new String[] { Long.toString(databaseId) }); try { ((LocalFolder) mFolder).deleteMessagePartsAndDataFromDisk(messagePartId); } catch (MessagingException e) { throw new WrappedException(e); } getFolder().deleteFulltextIndexEntry(db, databaseId); return null; } });
@Override public Void doDbWork(final SQLiteDatabase db) throws WrappedException, MessagingException { ContentValues cv = new ContentValues(); cv.putNull("message_part_id"); db.update("messages", cv, "id = ?", new String[] { Long.toString(databaseId) }); try { ((LocalFolder) mFolder).deleteMessagePartsAndDataFromDisk(messagePartId); } catch (MessagingException e) { throw new WrappedException(e); } setFlag(Flag.X_DOWNLOADED_FULL, false); setFlag(Flag.X_DOWNLOADED_PARTIAL, false); return null; } });
/** * The open interface for other classes in CRUD package to update. Using * baseObj to decide which table to update, and id to decide a specific row. * The value that need to update is stored in baseObj. * * @param baseObj * Which table to update by model instance. * @param id * Which record to update. * @return The number of rows affected. * @throws java.lang.reflect.InvocationTargetException * @throws IllegalAccessException * @throws NoSuchMethodException * @throws IllegalArgumentException * @throws SecurityException */ int onUpdate(LitePalSupport baseObj, long id) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { List<Field> supportedFields = getSupportedFields(baseObj.getClassName()); List<Field> supportedGenericFields = getSupportedGenericFields(baseObj.getClassName()); updateGenericTables(baseObj, supportedGenericFields, id); ContentValues values = new ContentValues(); putFieldsValue(baseObj, supportedFields, values); putFieldsToDefaultValue(baseObj, values, id); if (values.size() > 0) { return mDatabase.update(baseObj.getTableName(), values, "id = " + id, null); } return 0; }
private long updateOrInsertMessagePart(SQLiteDatabase db, ContentValues cv, Part part, long existingMessagePartId) throws IOException, MessagingException { byte[] headerBytes = getHeaderBytes(part); cv.put("mime_type", part.getMimeType()); cv.put("header", headerBytes); cv.put("type", MessagePartType.UNKNOWN); File file = null; Body body = part.getBody(); if (body instanceof Multipart) { multipartToContentValues(cv, (Multipart) body); } else if (body == null) { missingPartToContentValues(cv, part); } else if (body instanceof Message) { messageMarkerToContentValues(cv); } else { file = leafPartToContentValues(cv, part, body); } long messagePartId; if (existingMessagePartId != INVALID_MESSAGE_PART_ID) { messagePartId = existingMessagePartId; db.update("message_parts", cv, "id = ?", new String[] { Long.toString(messagePartId) }); } else { messagePartId = db.insertOrThrow("message_parts", null, cv); } if (file != null) { moveTemporaryFile(file, Long.toString(messagePartId)); } return messagePartId; }
@Override public Void doDbWork(final SQLiteDatabase db) throws WrappedException { ContentValues cv = new ContentValues(); cv.put("data_location", DataLocation.MISSING); db.update("message_parts", cv, null, null); return null; } });
String[] idArg = new String[] { Long.toString(msgId) }; ContentValues cv = new ContentValues(); cv.put("folder_id", lDestFolder.getDatabaseId()); cv.put("uid", newUid); db.update("messages", cv, "id = ?", idArg); cv.put("message_id", msgId); if (threadInfo.threadId == -1) { if (threadInfo.rootId != -1) { db.update("threads", cv, "id = ?", new String[] { Long.toString(threadInfo.threadId) }); db.update("messages", cv, "id = ?", new String[] { Long.toString(newId) }); } else { cv.put("message_id", newId); db.update("threads", cv, "id = ?", new String[] { Long.toString(lMessage.getThreadId()) });
null, null, null, null, null); try { ContentValues cv = new ContentValues(); while (cursor.moveToNext()) { cv.clear(); ContentValues cv = new ContentValues(); cv.putNull("thread_root"); cv.putNull("thread_parent"); db.update("messages", cv, null, null);
ContentValues cv = new ContentValues(); cv.put(GameColumns.IMEI, imei); mDb.update(GameColumns.TABLE, cv, null, null); + GameColumns.LAST_UPDATE + " TEXT," + GameColumns.NICKNAME + " TEXT);"); ContentValues cv = new ContentValues(); cv.put(GameColumns.IMEI, "123456789012345"); cv.put(GameColumns.LAST_UPDATE, 0);
@Override public void updateConnectionModel(int id, int index, long currentOffset) { final ContentValues values = new ContentValues(); values.put(ConnectionModel.CURRENT_OFFSET, currentOffset); db.update(CONNECTION_TABLE_NAME, values, ConnectionModel.ID + " = ? AND " + ConnectionModel.INDEX + " = ?", new String[]{Integer.toString(id), Integer.toString(index)}); }
ContentValues cv = new ContentValues(); cv.put("message_part_id", rootMessagePartId); cv.put("uid", uid); cv.put("subject", message.getSubject()); cv.put("sender_list", Address.pack(message.getFrom())); cv.put("date", message.getSentDate() == null } else { msgId = oldMessageId; db.update("messages", cv, "id = ?", new String[] { Long.toString(oldMessageId) });
/** * When the associations breaks between current model and associated models, * clear all the associated models' foreign key value if it exists. * * @param baseObj * Current model that is persisted. */ private void clearFKValueInAssociatedTable(LitePalSupport baseObj) { List<String> associatedTableNames = baseObj.getListToClearAssociatedFK(); for (String associatedTableName : associatedTableNames) { String fkColumnName = getForeignKeyColumnName(baseObj.getTableName()); ContentValues values = new ContentValues(); values.putNull(fkColumnName); String whereClause = fkColumnName + " = " + baseObj.getBaseObjId(); mDatabase.update(associatedTableName, values, whereClause, null); } }
public void insert(SQLiteDatabase db) { ContentValues values = new ContentValues(); values.put(Table.COLUMN_NAME_TITLE, "your title"); String selection = Table.COLUMN_NAME_TITLE + " LIKE ?"; String[] selectionArgs = {"MyTitle"}; int count = db.update( Table.TABLE_NAME, values, selection, selectionArgs); }
private void upgradeFrom2To3(SQLiteDatabase db) { db.execSQL("alter table " + JOB_TABLE_NAME + " add column " + COLUMN_FLEX_MS + " integer;"); db.execSQL("alter table " + JOB_TABLE_NAME + " add column " + COLUMN_FLEX_SUPPORT + " integer;"); // adjust interval to minimum value if necessary ContentValues contentValues = new ContentValues(); contentValues.put(COLUMN_INTERVAL_MS, JobRequest.MIN_INTERVAL); db.update(JOB_TABLE_NAME, contentValues, COLUMN_INTERVAL_MS + ">0 AND " + COLUMN_INTERVAL_MS + "<" + JobRequest.MIN_INTERVAL, new String[0]); // copy interval into flex column, that's the default value and the flex support mode is not required db.execSQL("update " + JOB_TABLE_NAME + " set " + COLUMN_FLEX_MS + " = " + COLUMN_INTERVAL_MS + ";"); }
@Override public void updateProgress(int id, long downloadedBytes, long lastModifiedAt) { try { ContentValues values = new ContentValues(); values.put(DownloadModel.DOWNLOADED_BYTES, downloadedBytes); values.put(DownloadModel.LAST_MODIFIED_AT, lastModifiedAt); db.update(TABLE_NAME, values, DownloadModel.ID + " = ? ", new String[]{String.valueOf(id)}); } catch (Exception e) { e.printStackTrace(); } }
public boolean updateCar(Integer id, String name, String color, float mileage) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put("name", name); contentValues.put("color", color); contentValues.put("mileage", mileage); db.update("cars", contentValues, "id = ? ", new String[]{Integer.toString(id)}); return true; }
public boolean updateContact(Integer id, String name, String phone, String email, String street, String place) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put("name", name); contentValues.put("phone", phone); contentValues.put("email", email); contentValues.put("street", street); contentValues.put("place", place); db.update("contacts", contentValues, "id = ? ", new String[]{Integer.toString(id)}); return true; }
public synchronized void update(long playlistid, long id, int order) { final SQLiteDatabase database = mMusicDatabase.getWritableDatabase(); database.beginTransaction(); try { ContentValues values = new ContentValues(1); values.put(PlaylistsColumns.TRACK_ORDER, order); database.update(PlaylistsColumns.NAME, values, PlaylistsColumns.PLAYLIST_ID + " = ?" + " AND " + PlaylistsColumns.TRACK_ID + " = ?", new String[]{playlistid + "", id + ""}); database.setTransactionSuccessful(); } finally { database.endTransaction(); } }
private void writeValue(SQLiteDatabase mDb, String key, String value) { if (value == null) { mDb.delete("preferences_storage", "primkey = ?", new String[] { key }); return; } ContentValues cv = new ContentValues(); cv.put("primkey", key); cv.put("value", value); long result = mDb.update("preferences_storage", cv, "primkey = ?", new String[] { key }); if (result == -1) { Timber.e("Error writing key '%s', value = '%s'", key, value); } }
public synchronized void update(long playlistid, int count) { final SQLiteDatabase database = mMusicDatabase.getWritableDatabase(); database.beginTransaction(); try { ContentValues values = new ContentValues(2); values.put(PlaylistInfoColumns.PLAYLIST_ID, playlistid); //values.put(PlaylistInfoColumns.PLAYLIST_NAME, name); values.put(PlaylistInfoColumns.SONG_COUNT, count); database.update(PlaylistInfoColumns.NAME, values, PlaylistInfoColumns.PLAYLIST_ID + " = " + playlistid, null); database.setTransactionSuccessful(); } finally { database.endTransaction(); } }