List of usage examples for android.content ContentValues ContentValues
private ContentValues(Parcel in)
From source file:com.android.mail.browse.AttachmentActionHandler.java
private void startDownloadingAttachment(Attachment attachment, int destination, int rendition, int additionalPriority, boolean delayDownload) { //do not auto install apk from stream . must save first so that can be install if (attachment.state == AttachmentState.SAVED && destination == AttachmentDestination.EXTERNAL && !MimeType.isInstallable(attachment.getContentType())) { File savedFile = performAttachmentSave(attachment); if (savedFile != null && mView != null) { // The attachment is saved successfully from cache. mView.viewAttachment();/*ww w .j av a 2s.co m*/ return; } } final ContentValues params = new ContentValues(5); params.put(AttachmentColumns.STATE, AttachmentState.DOWNLOADING); params.put(AttachmentColumns.DESTINATION, destination); params.put(AttachmentContentValueKeys.RENDITION, rendition); params.put(AttachmentContentValueKeys.ADDITIONAL_PRIORITY, additionalPriority); params.put(AttachmentContentValueKeys.DELAY_DOWNLOAD, delayDownload); mCommandHandler.sendCommand(attachment.uri, params); }
From source file:com.smarthome.deskclock.Alarms.java
private static ContentValues createContentValues(Alarm alarm) { ContentValues values = new ContentValues(8); // Set the alarm_time value if this alarm does not repeat. This will be // used later to disable expire alarms. long time = 0; if (!alarm.daysOfWeek.isRepeatSet()) { time = calculateAlarm(alarm);//from ww w . j av a 2 s. co m } values.put(Alarm.Columns.ENABLED, alarm.enabled ? 1 : 0); values.put(Alarm.Columns.HOUR, alarm.hour); values.put(Alarm.Columns.MINUTES, alarm.minutes); values.put(Alarm.Columns.ALARM_TIME, alarm.time); values.put(Alarm.Columns.DAYS_OF_WEEK, alarm.daysOfWeek.getCoded()); values.put(Alarm.Columns.VIBRATE, alarm.vibrate); values.put(Alarm.Columns.MESSAGE, alarm.label); // A null alert Uri indicates a silent alarm. values.put(Alarm.Columns.ALERT, alarm.alert == null ? ALARM_ALERT_SILENT : alarm.alert.toString()); values.put(Alarm.Columns.OPERATION, alarm.operation); values.put(Alarm.Columns.MUSIC, alarm.musicPath); return values; }
From source file:at.bitfire.davdroid.resource.LocalTaskList.java
@Override public void setCTag(String cTag) throws LocalStorageException { ContentValues values = new ContentValues(1); values.put(COLLECTION_COLUMN_CTAG, cTag); try {//from www .j av a2 s.co m providerClient.update(ContentUris.withAppendedId(taskListsURI(account), id), values, null, null); } catch (RemoteException e) { throw new LocalStorageException(e); } }
From source file:com.inferiorhumanorgans.WayToGo.Agency.BART.Station.StationTask.java
public void addStation(final ContentValues aStation) { Log.d(LOG_NAME, "Trying to initially add station of: (" + aStation.getAsString("tag") + ") " + aStation); theStations.put(aStation.getAsString("tag"), new ContentValues(aStation)); }
From source file:com.android.mail.browse.AttachmentActionHandler.java
public void cancelAttachment() { final ContentValues params = new ContentValues(1); params.put(AttachmentColumns.STATE, AttachmentState.NOT_SAVED); mCommandHandler.sendCommand(mAttachment.uri, params); }
From source file:org.zoumbox.mh_dla_notifier.sp.PublicScriptsProxy.java
protected static void saveFetch(Context context, PublicScript script, String trollId, String uuid, String status) {/*from w w w . ja va 2 s . c o m*/ String format = "Saving fetch for category %s (script=%s) and troll=%s"; String message = String.format(format, script.category, script, trollId); Log.d(TAG, message); MhDlaSQLHelper helper = new MhDlaSQLHelper(context); SQLiteDatabase database = helper.getWritableDatabase(); ContentValues values = new ContentValues(2); long now = System.currentTimeMillis(); values.put(MhDlaSQLHelper.SCRIPTS_END_DATE_COLUMN, now); values.put(MhDlaSQLHelper.SCRIPTS_STATUS_COLUMN, status); String whereClause = String.format("%s = ?", MhDlaSQLHelper.SCRIPTS_ID_COLUMN); database.update(MhDlaSQLHelper.SCRIPTS_TABLE, values, whereClause, new String[] { uuid }); database.close(); }
From source file:com.android.mail.browse.AttachmentActionHandler.java
public void startRedownloadingAttachment(Attachment attachment) { final ContentValues params = new ContentValues(2); params.put(AttachmentColumns.STATE, AttachmentState.REDOWNLOADING); params.put(AttachmentColumns.DESTINATION, attachment.destination); mCommandHandler.sendCommand(attachment.uri, params); }
From source file:com.android.exchange.service.EasServerConnection.java
public void redirectHostAuth(final String newAddress) { mClient = null;/* www . java2 s . co m*/ mHostAuth.mAddress = newAddress; if (mHostAuth.isSaved()) { EasConnectionCache.instance().uncacheConnectionManager(mHostAuth); final ContentValues cv = new ContentValues(1); cv.put(EmailContent.HostAuthColumns.ADDRESS, newAddress); mHostAuth.update(mContext, cv); } }
From source file:pl.selvin.android.syncframework.content.TableInfo.java
public void GetChanges(SQLiteDatabase db, JsonGenerator gen, ArrayList<TableInfo> notifyTableInfo) throws IOException { String[] cols = new String[columns.length + 3]; int i = 0;/* w w w . j a v a 2 s .c o m*/ for (; i < columns.length; i++) cols[i] = columns[i].name; cols[i] = _.uri; cols[i + 1] = _.tempId; cols[i + 2] = _.isDeleted; Cursor c = db.query(name, cols, _.isDirtyP, new String[] { "1" }, null, null, null); //to fix startPos > actual rows for large cursors db operations should be done after cursor is closed ... final ArrayList<OperationHolder> operations = new ArrayList<OperationHolder>(); if (c.moveToFirst()) { if (!notifyTableInfo.contains(this)) notifyTableInfo.add(this); do { gen.writeStartObject(); gen.writeObjectFieldStart(_.__metadata); gen.writeBooleanField(_.isDirty, true); gen.writeStringField(_.type, scope_name); //Log.d("before", scope_name + ":" + c.getLong(i + 3)); String uri = c.getString(i); //Log.d("after", scope_name + ":" + c.getLong(i + 3)); if (uri == null) { gen.writeStringField(_.tempId, c.getString(i + 1)); } else { gen.writeStringField(_.uri, uri); final ContentValues update = new ContentValues(1); update.put(_.isDirty, 0); operations.add(new OperationHolder(name, OperationHolder.UPDATE, update, uri)); } boolean isDeleted = c.getInt(i + 2) == 1; if (isDeleted) { gen.writeBooleanField(_.isDeleted, true); gen.writeEndObject();// meta operations.add(new OperationHolder(name, OperationHolder.DELETE, null, uri)); } else { gen.writeEndObject();// meta for (i = 0; i < columns.length; i++) { if (columns[i].nullable && c.isNull(i)) { gen.writeNullField(columns[i].name); } else { switch (columns[i].type) { case ColumnType.BLOB: gen.writeBinaryField(columns[i].name, c.getBlob(i)); break; case ColumnType.BOOLEAN: gen.writeBooleanField(columns[i].name, c.getLong(i) == 1); break; case ColumnType.INTEGER: gen.writeNumberField(columns[i].name, c.getLong(i)); break; case ColumnType.DATETIME: try { gen.writeStringField(columns[i].name, String.format(msdate, sdf.parse(c.getString(i)).getTime())); } catch (Exception e) { if (BuildConfig.DEBUG) { Log.e("ListSync", e.getLocalizedMessage()); } } break; case ColumnType.NUMERIC: gen.writeNumberField(columns[i].name, c.getDouble(i)); break; default: gen.writeStringField(columns[i].name, c.getString(i)); break; } } } } gen.writeEndObject(); // end of row } while (c.moveToNext()); } c.close(); for (OperationHolder operation : operations) operation.execute(db); }
From source file:com.granita.contacticloudsync.resource.LocalCalendar.java
@Override public void setCTag(String cTag) throws CalendarStorageException, ContactsStorageException { try {/*from w ww . java 2 s . c om*/ ContentValues values = new ContentValues(1); values.put(COLUMN_CTAG, cTag); provider.update(calendarSyncURI(), values, null, null); } catch (RemoteException e) { throw new CalendarStorageException("Couldn't write local (last known) CTag", e); } }