当前位置: 首页>>代码示例>>Java>>正文


Java ContentValues.remove方法代码示例

本文整理汇总了Java中android.content.ContentValues.remove方法的典型用法代码示例。如果您正苦于以下问题:Java ContentValues.remove方法的具体用法?Java ContentValues.remove怎么用?Java ContentValues.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ContentValues的用法示例。


在下文中一共展示了ContentValues.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCorrectValues

import android.content.ContentValues; //导入方法依赖的package包/类
/**获取正确的的ContentValues,防止数据库操作出错
 * @param values
 * @return
 */
public ContentValues getCorrectValues(ContentValues values) {
	if (values == null || values.size() <= 0) {
		return null;
	}

	//去除所有空key
	Set<String> set = values.keySet();
	for (String key : set) {
		if (StringUtil.isNotEmpty(key, true) == false) {
			values.remove(key);
		}
	}

	return values;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:SQLHelper.java

示例2: insert

import android.content.ContentValues; //导入方法依赖的package包/类
@Override
public Uri insert(Uri uri, ContentValues values) {

    if (MATCHER.match(uri) != CODE_LIST) {
        throw new UnsupportedOperationException("Insert not supported for " + uri + ".");
    }

    if (!values.containsKey(Cols.Package.NAME)) {
        throw new IllegalStateException("Package name not provided to InstalledAppProvider");
    }

    String packageName = values.getAsString(Cols.Package.NAME);
    long packageId = PackageProvider.Helper.ensureExists(getContext(), packageName);
    values.remove(Cols.Package.NAME);
    values.put(Cols.PACKAGE_ID, packageId);

    verifyVersionNameNotNull(values);

    Utils.debugLog(TAG, "Inserting/updating " + packageName);
    db().replaceOrThrow(getTableName(), null, values);

    Utils.debugLog(TAG, "Requesting the suggested apk get recalculated for  " + packageName);
    AppProvider.Helper.calcSuggestedApk(getContext(), packageName);

    return getAppUri(values.getAsString(Cols.Package.NAME));
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:27,代码来源:InstalledAppProvider.java

示例3: insert

import android.content.ContentValues; //导入方法依赖的package包/类
@Override
public Uri insert(Uri uri, ContentValues values) {
    boolean saveAntiFeatures = false;
    String[] antiFeatures = null;
    if (values.containsKey(Cols.AntiFeatures.ANTI_FEATURES)) {
        saveAntiFeatures = true;
        String antiFeaturesString = values.getAsString(Cols.AntiFeatures.ANTI_FEATURES);
        antiFeatures = Utils.parseCommaSeparatedString(antiFeaturesString);
        values.remove(Cols.AntiFeatures.ANTI_FEATURES);
    }

    removeFieldsFromOtherTables(values);
    validateFields(Cols.ALL, values);
    long newId = db().insertOrThrow(getTableName(), null, values);

    if (saveAntiFeatures) {
        ensureAntiFeatures(antiFeatures, newId);
    }

    if (!isApplyingBatch()) {
        getContext().getContentResolver().notifyChange(uri, null);
    }
    return getApkUri(newId);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:25,代码来源:ApkProvider.java

示例4: saveOrUpdate

import android.content.ContentValues; //导入方法依赖的package包/类
public long saveOrUpdate(Object entity) {
	if (entity == null) {
		throw new IllegalArgumentException("Entity is null");
	}
       SQLiteDatabase db = db();
	EntityDefinition ed = getEntityDefinitionOrThrow(entity.getClass());
	ContentValues values = getContentValues(ed, entity);
	long id = ed.getId(entity);
	values.remove("updated_on");
	values.put("updated_on", System.currentTimeMillis());			
	if (id <= 0) {
		values.remove(ed.idField.columnName);		
		id = db.insertOrThrow(ed.tableName, null, values);
           ed.setId(entity, id);
           return id;
	} else {
		values.remove("updated_on");
		values.put("updated_on", System.currentTimeMillis());
		db.update(ed.tableName, values, ed.idField.columnName+"=?", new String[]{String.valueOf(id)});
		return id;
	}
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:23,代码来源:EntityManager.java

示例5: savePubkey

import android.content.ContentValues; //导入方法依赖的package包/类
/**
 * @param pubkey
 */
public PubkeyBean savePubkey(PubkeyBean pubkey) {
	boolean success = false;

	ContentValues values = pubkey.getValues();

	mDb.beginTransaction();
	try {
		if (pubkey.getId() > 0) {
			values.remove("_id");
			if (mDb.update(TABLE_PUBKEYS, values, "_id = ?", new String[] {String.valueOf(pubkey.getId())}) > 0)
				success = true;
		}

		if (!success) {
			long id = mDb.insert(TABLE_PUBKEYS, null, pubkey.getValues());
			if (id != -1) {
				// TODO add some error handling here?
				pubkey.setId(id);
			}
		}

		mDb.setTransactionSuccessful();
	} finally {
		mDb.endTransaction();
	}
	return pubkey;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:PubkeyDatabase.java

示例6: insertOrUpdate

import android.content.ContentValues; //导入方法依赖的package包/类
/**
 * Tries to insert the values. If it fails because the item already exists it tries to update
 * the item.
 *
 * @param sqlDb                  database to work with. has to be writable
 * @param table                  the table to insert
 * @param selection              selection to detect a already inserted item
 * @param selectionArgs          keys of the contentValues. there values will be used as the
 *                               selectionArgs for the param selection
 * @param values                 the values to insert
 * @param excludeFieldsForUpdate contentValues keys which should be deleted before the update
 * @return 1 for insert, 0 for update and -1 if something goes wrong
 */
public static int insertOrUpdate(@Nullable SQLiteDatabase sqlDb, String table,
        @Nullable String selection, String[] selectionArgs, @NonNull final ContentValues values,
        @Nullable final String[] excludeFieldsForUpdate) {
    if (sqlDb == null) {
        return -1;
    }

    final long items = DatabaseUtils.queryNumEntries(sqlDb, table, selection, selectionArgs);

    if (items == 0) {
        // insert, item doesn't exist
        final long row = sqlDb.insert(table, null, values);
        if (row == -1) {
            // unknown error
            return -1;
        }
        // success, inserted
        return 1;
    } else {
        // update existing item

        if (excludeFieldsForUpdate != null) {
            for (String excludeField : excludeFieldsForUpdate) {
                values.remove(excludeField);
            }
        }

        sqlDb.update(table, values, selection, selectionArgs);

        // handling the update error is not needed. All possible errors are thrown by the
        // DatabaseUtils.queryNumEntries() (which uses the same params).
        // a wrong selection results only in an insert. update will never called then.
        return 0;
    }
}
 
开发者ID:sfilmak,项目名称:MakiLite,代码行数:49,代码来源:SqliteHelper.java

示例7: update

import android.content.ContentValues; //导入方法依赖的package包/类
public void update(SyncContext context, long localEventId)
    throws android.os.RemoteException,
           android.database.sqlite.SQLiteException
{
    ContentValues values = new ContentValues(mValues);
    values.remove(CalendarContract.Events._ID);
    values.remove(CalendarContract.Events.UID_2445);
    values.remove(CalendarContract.Events.CALENDAR_ID);

    context.getContentProviderClient().update(
            CalendarContract.Events.CONTENT_URI.buildUpon()
                    .appendQueryParameter(CalendarContract.SyncState.ACCOUNT_TYPE, context.getContext().getString(R.string.account_type))
                    .appendQueryParameter(CalendarContract.SyncState.ACCOUNT_NAME, context.getAccount().name)
                    .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
                    .build(),
            values,
            String.format("(%s = ?)", CalendarContract.Events._ID),
            new String[] { String.valueOf(localEventId) });

    HashMap<Integer /* minutes */, Long /* reminder ID */> reminders = getLocalReminders(context, localEventId);
    Set<Integer> localReminderSet = reminders.keySet();
    Set<Integer> configuredReminders = mCalendar.getReminderIntervals();

    // Silly Java can't even subtract Sets...*sigh*
    Set<Integer> toAdd = new HashSet<>();
    toAdd.addAll(configuredReminders);
    toAdd.removeAll(localReminderSet);

    Set<Integer> toRemove = new HashSet<>();
    toRemove.addAll(localReminderSet);
    toRemove.removeAll(configuredReminders);

    if (!toAdd.isEmpty()) {
        createReminders(context, localEventId, toAdd);
    }
    for (int reminder : toRemove) {
        removeReminder(context, reminders.get(reminder));
    }
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:40,代码来源:FBEvent.java

示例8: enforceAllowedValues

import android.content.ContentValues; //导入方法依赖的package包/类
/**
 * Remove column from values, and throw a SecurityException if the value isn't within the
 * specified allowedValues.
 */
private void enforceAllowedValues(ContentValues values, String column,
                                  Object... allowedValues) {
    Object value = values.get(column);
    values.remove(column);
    for (Object allowedValue : allowedValues) {
        if (value == null && allowedValue == null) {
            return;
        }
        if (value != null && value.equals(allowedValue)) {
            return;
        }
    }
    throw new SecurityException("Invalid value for " + column + ": " + value);
}
 
开发者ID:redleaf2002,项目名称:downloadmanager,代码行数:19,代码来源:DownloadProvider.java

示例9: insert

import android.content.ContentValues; //导入方法依赖的package包/类
@Override
public Uri insert(Uri uri, ContentValues values) {
    long packageId = PackageProvider.Helper.ensureExists(getContext(), values.getAsString(Cols.Package.PACKAGE_NAME));
    values.remove(Cols.Package.PACKAGE_NAME);
    values.put(Cols.PACKAGE_ID, packageId);

    if (!values.containsKey(Cols.DESCRIPTION) || values.getAsString(Cols.DESCRIPTION) == null) {
        // the current structure assumes that description is always present and non-null
        values.put(Cols.DESCRIPTION, "");
    }

    String[] categories = null;
    boolean saveCategories = false;
    if (values.containsKey(Cols.ForWriting.Categories.CATEGORIES)) {
        // Hold onto these categories, so that after we have an ID to reference the newly inserted
        // app metadata we can then specify its categories.
        saveCategories = true;
        categories = Utils.parseCommaSeparatedString(values.getAsString(Cols.ForWriting.Categories.CATEGORIES));
        values.remove(Cols.ForWriting.Categories.CATEGORIES);
    }

    long appMetadataId = db().insertOrThrow(getTableName(), null, values);
    if (!isApplyingBatch()) {
        getContext().getContentResolver().notifyChange(uri, null);
    }

    if (saveCategories) {
        ensureCategories(categories, appMetadataId);
    }

    return getSpecificAppUri(values.getAsString(PackageTable.Cols.PACKAGE_NAME), values.getAsLong(Cols.REPO_ID));
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:33,代码来源:AppProvider.java

示例10: performUpdate

import android.content.ContentValues; //导入方法依赖的package包/类
private void performUpdate(ContentValues values) {
    StringBuilder where = new StringBuilder();
    where.append(DatabaseContract.TableTransactions.COL_ID)
            .append(" = ?");
    String id = values.getAsString(DatabaseContract.TableTransactions.COL_ID);
    values.remove(DatabaseContract.TableTransactions.COL_ID);
    if (getContentResolver().update(DatabaseContract.CONTENT_URI, values, where.toString(), new String[]{id}) > 0) {
        Log.d(TAG, "Updated new Transaction");
    } else {
        Log.w(TAG, "Error inserting new Transaction");
    }
}
 
开发者ID:talCrafts,项目名称:Udhari,代码行数:13,代码来源:AddTxService.java

示例11: update

import android.content.ContentValues; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    String accountName = getCurrentAccountName(uri, false);
    LOGV(TAG, "update(uri=" + uri + ", values=" + values.toString()
            + ", account=" + accountName + ")");

    final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    ScheduleUriEnum matchingUriEnum = mUriMatcher.matchUri(uri);
    if (matchingUriEnum == ScheduleUriEnum.SEARCH_INDEX) {
        // update the search index
        ScheduleDatabase.updateSessionSearchIndex(db);
        return 1;
    }

    final SelectionBuilder builder = buildSimpleSelection(uri);
    if (matchingUriEnum == ScheduleUriEnum.MY_SCHEDULE) {
        values.remove(MySchedule.MY_SCHEDULE_ACCOUNT_NAME);
        builder.where(MySchedule.MY_SCHEDULE_ACCOUNT_NAME + "=?", accountName);
    }
    if (matchingUriEnum == ScheduleUriEnum.MY_VIEWED_VIDEOS) {
        values.remove(MyViewedVideos.MY_VIEWED_VIDEOS_ACCOUNT_NAME);
        builder.where(MyViewedVideos.MY_VIEWED_VIDEOS_ACCOUNT_NAME + "=?", accountName);
    }
    if (matchingUriEnum == ScheduleUriEnum.MY_FEEDBACK_SUBMITTED) {
        values.remove(MyFeedbackSubmitted.MY_FEEDBACK_SUBMITTED_ACCOUNT_NAME);
        builder.where(MyFeedbackSubmitted.MY_FEEDBACK_SUBMITTED_ACCOUNT_NAME + "=?",
                accountName);
    }

    int retVal = builder.where(selection, selectionArgs).update(db, values);
    notifyChange(uri);
    return retVal;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:35,代码来源:ScheduleProvider.java

示例12: updateCategory

import android.content.ContentValues; //导入方法依赖的package包/类
private void updateCategory(long id, String title, int type) {
	ContentValues values = new ContentValues();
	values.put(CategoryColumns.title.name(), title);
       values.put(CategoryColumns.type.name(), type);
       values.remove("updated_on");     
       values.put(CategoryColumns.updated_on.name(), System.currentTimeMillis());        
	db().update(CATEGORY_TABLE, values, CategoryColumns._id+"=?", new String[]{String.valueOf(id)});
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:9,代码来源:DatabaseAdapter.java

示例13: insertAttribute

import android.content.ContentValues; //导入方法依赖的package包/类
private long insertAttribute(Attribute attribute) {
	ContentValues values = attribute.toValues();
	values.remove("updated_on");     
       values.put(CategoryColumns.updated_on.name(), System.currentTimeMillis());
       values.put(CategoryColumns.remote_key.name(), attribute.remoteKey);        	
	return db().insert(ATTRIBUTES_TABLE, null, values);
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:8,代码来源:DatabaseAdapter.java

示例14: updateAttribute

import android.content.ContentValues; //导入方法依赖的package包/类
private void updateAttribute(Attribute attribute) {
	ContentValues values = attribute.toValues();
       values.remove("updated_on");     
       values.put(CategoryColumns.updated_on.name(), System.currentTimeMillis());
       values.put(CategoryColumns.remote_key.name(), attribute.remoteKey);		
	db().update(ATTRIBUTES_TABLE, values, AttributeColumns.ID+"=?", new String[]{String.valueOf(attribute.id)});
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:8,代码来源:DatabaseAdapter.java

示例15: saveRateInTransaction

import android.content.ContentValues; //导入方法依赖的package包/类
private void saveRateInTransaction(SQLiteDatabase db, ExchangeRate r) {
    ContentValues values = r.toValues();
    values.remove("updated_on");     
    values.put(CategoryColumns.updated_on.name(), System.currentTimeMillis());          
    db.insert(EXCHANGE_RATES_TABLE, null, values);
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:7,代码来源:DatabaseAdapter.java


注:本文中的android.content.ContentValues.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。