List of usage examples for android.content ContentValues containsKey
public boolean containsKey(String key)
From source file:Main.java
public static ArrayList<ContentValues> removeEntriesWhenPresent( HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName) { ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations) { return null; }/* ww w . j ava 2s . c o m*/ ArrayList<ContentValues> removeOperations = new ArrayList<ContentValues>(); for (ContentValues restoreCv : restoreOperations) { if (restoreCv.containsKey(idColumnName)) { removeOperations.add(restoreCv); } } for (ContentValues removeCv : removeOperations) { restoreOperations.remove(removeCv); } return removeOperations; }
From source file:Main.java
public static ArrayList<ContentValues> removeEntriesWhenEquals( HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName, String compareValue) {/*ww w . ja va 2 s .co m*/ ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations || null == compareValue) { return null; } ArrayList<ContentValues> removeOperations = new ArrayList<ContentValues>(); for (ContentValues restoreCv : restoreOperations) { if (restoreCv.containsKey(idColumnName) && compareValue.equals(restoreCv.getAsString(idColumnName))) { removeOperations.add(restoreCv); } } for (ContentValues removeCv : removeOperations) { restoreOperations.remove(removeCv); } return removeOperations; }
From source file:Main.java
public static void shiftTableUriIds(HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName, String authority, String path, long topTableId) { ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations) { return;/*from w w w .j a va2 s. co m*/ } for (ContentValues restoreCv : restoreOperations) { if (restoreCv.containsKey(idColumnName) && null != restoreCv.getAsString(idColumnName)) { Uri uri = Uri.parse(restoreCv.getAsString(idColumnName)); if ("content".equalsIgnoreCase(uri.getScheme()) && authority.equals(uri.getAuthority()) && uri.getPath().substring(0, uri.getPath().lastIndexOf('/')).equals(path)) { Uri.Builder newUri = uri.buildUpon() .path(uri.getPath().substring(0, uri.getPath().lastIndexOf('/'))) .appendPath(String.valueOf( Long.parseLong(uri.getPath().substring(uri.getPath().lastIndexOf('/') + 1)) + topTableId)); // Log.v("URI", uri.getPath().substring(uri.getPath().lastIndexOf('/')+1)); // Log.v("URI", String.valueOf(Long.parseLong(uri.getPath().substring(uri.getPath().lastIndexOf('/')+1)) + topTableId)); restoreCv.put(idColumnName, newUri.build().toString()); } } } }
From source file:Main.java
public static void removeEntriesWhereMatch(HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName, ArrayList<ContentValues> compareContentValues, String compareColumnName) { ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations) { return;/*from w w w .j a va 2s . c o m*/ } ArrayList<ContentValues> removeOperations = new ArrayList<ContentValues>(); for (ContentValues restoreCv : restoreOperations) { for (ContentValues compareCv : compareContentValues) { if (restoreCv.containsKey(idColumnName) && compareCv.containsKey(compareColumnName)) { if (restoreCv.getAsLong(idColumnName) == compareCv.getAsLong(compareColumnName)) { removeOperations.add(restoreCv); } } } } for (ContentValues removeCv : removeOperations) { restoreOperations.remove(removeCv); } }
From source file:com.abcvoipsip.ui.favorites.FavAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { ContentValues cv = new ContentValues(); DatabaseUtils.cursorRowToContentValues(cursor, cv); int type = ContactsWrapper.TYPE_CONTACT; if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) { type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE); }/*from w ww .jav a 2 s . c o m*/ if (type == ContactsWrapper.TYPE_GROUP) { showViewForHeader(view, true); TextView tv = (TextView) view.findViewById(R.id.header_text); ImageView icon = (ImageView) view.findViewById(R.id.header_icon); PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view .findViewById(R.id.header_presence_spinner); tv.setText(cv.getAsString(SipProfile.FIELD_DISPLAY_NAME)); icon.setImageResource(WizardUtils.getWizardIconRes(cv.getAsString(SipProfile.FIELD_WIZARD))); presSpinner.setProfileId(cv.getAsLong(BaseColumns._ID)); } else { showViewForHeader(view, false); ContactsWrapper.getInstance().bindContactView(view, context, cursor); } }
From source file:com.csipsimple.utils.Columns.java
public JSONObject contentValueToJSON(ContentValues cv) { JSONObject json = new JSONObject(); try {//from w w w. j a va 2 s. c o m for (int i = 0; i < names.length; i++) { if (!cv.containsKey(names[i])) { continue; } switch (types[i]) { case STRING: json.put(names[i], cv.getAsString(names[i])); break; case INT: json.put(names[i], cv.getAsInteger(names[i])); break; case LONG: json.put(names[i], cv.getAsLong(names[i])); break; case FLOAT: json.put(names[i], cv.getAsFloat(names[i])); break; case DOUBLE: json.put(names[i], cv.getAsDouble(names[i])); break; case BOOLEAN: json.put(names[i], cv.getAsBoolean(names[i])); break; } } } catch (JSONException e) { throw new RuntimeException(e); } return json; }
From source file:com.wheelly.activity.FilterDialog.java
private void updateLocationFromFilter(ContentValues filter, final Cursor locationCursor) { long locationId = filter.containsKey(F.LOCATION) ? filter.getAsLong(F.LOCATION) : 0; if (locationId > 0 && Utils.moveCursor(locationCursor, BaseColumns._ID, locationId) != -1) { final ContentValues location = LocationBroker.deserialize(locationCursor); c.location.setText(location != null ? location.getAsString("name") : filterValueNotFound); } else {// w w w.j a v a 2 s . co m c.location.setText(R.string.no_filter); } }
From source file:com.csipsimple.backup.Columns.java
public JSONObject contentValueToJSON(ContentValues cv) { JSONObject json = new JSONObject(); for (int i = 0; i < names.size(); i++) { if (!cv.containsKey(names.get(i))) { continue; }// w w w.j a va 2 s. c o m try { String name = names.get(i); switch (types.get(i)) { case STRING: json.put(name, cv.getAsString(name)); break; case INT: json.put(name, cv.getAsInteger(name)); break; case LONG: json.put(name, cv.getAsLong(name)); break; case FLOAT: json.put(name, cv.getAsFloat(name)); break; case DOUBLE: json.put(name, cv.getAsDouble(name)); break; case BOOLEAN: json.put(name, cv.getAsBoolean(name)); break; default: Log.w("Col", "Invalid type, can't unserialize " + types.get(i)); } } catch (JSONException e) { Log.e("Col", "Invalid type, can't unserialize ", e); } } return json; }
From source file:at.bitfire.ical4android.AndroidTaskList.java
protected void populate(ContentValues values) { syncId = values.getAsString(TaskLists._SYNC_ID); name = values.getAsString(TaskLists.LIST_NAME); if (values.containsKey(TaskLists.LIST_COLOR)) color = values.getAsInteger(TaskLists.LIST_COLOR); if (values.containsKey(TaskLists.SYNC_ENABLED)) isSynced = values.getAsInteger(TaskLists.SYNC_ENABLED) != 0; if (values.containsKey(TaskLists.VISIBLE)) isVisible = values.getAsInteger(TaskLists.VISIBLE) != 0; }
From source file:com.todoroo.astrid.gcal.GCalControlSet.java
@Override protected void writeToModelAfterInitialized(Task task) { if (!task.hasDueDate()) { return;/* w w w . java 2 s. c om*/ } if ((gcal.isDefaultCalendarSet() || calendarSelector.getSelectedItemPosition() != 0) && calendarUri == null) { try { ContentResolver cr = activity.getContentResolver(); ContentValues values = new ContentValues(); String calendarId = calendars.calendarIds[calendarSelector.getSelectedItemPosition() - 1]; values.put("calendar_id", calendarId); calendarUri = gcal.createTaskEvent(task, cr, values); if (calendarUri != null) { task.setCalendarUri(calendarUri.toString()); if (calendarSelector.getSelectedItemPosition() != 0 && !hasEvent) { // pop up the new event Intent intent = new Intent(Intent.ACTION_VIEW, calendarUri); intent.putExtra("beginTime", values.getAsLong("dtstart")); intent.putExtra("endTime", values.getAsLong("dtend")); activity.startActivity(intent); } } } catch (Exception e) { log.error(e.getMessage(), e); } } else if (calendarUri != null) { try { ContentValues updateValues = new ContentValues(); // check if we need to update the item ContentValues setValues = task.getSetValues(); if (setValues.containsKey(Task.TITLE.name)) { updateValues.put("title", task.getTitle()); } if (setValues.containsKey(Task.NOTES.name)) { updateValues.put("description", task.getNotes()); } if (setValues.containsKey(Task.DUE_DATE.name) || setValues.containsKey(Task.ESTIMATED_SECONDS.name)) { gcal.createStartAndEndDate(task, updateValues); } ContentResolver cr = activity.getContentResolver(); cr.update(calendarUri, updateValues, null, null); } catch (Exception e) { log.error("unable-to-update-calendar: " + task.getCalendarURI(), e); } } }