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


Java ContentValues.valueSet方法代码示例

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


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

示例1: validateCurrentRecord

import android.content.ContentValues; //导入方法依赖的package包/类
/**
 * This method iterates through a set of expected values and makes various assertions that
 * will pass if our app is functioning properly.
 *
 * @param error          Message when an error occurs
 * @param valueCursor    The Cursor containing the actual values received from an arbitrary query
 * @param expectedValues The values we expect to receive in valueCursor
 */
static void validateCurrentRecord(String error, Cursor valueCursor, ContentValues expectedValues) {
    Set<Map.Entry<String, Object>> valueSet = expectedValues.valueSet();

    for (Map.Entry<String, Object> entry : valueSet) {
        String columnName = entry.getKey();
        int index = valueCursor.getColumnIndex(columnName);

        /* Test to see if the column is contained within the cursor */
        String columnNotFoundError = "Column '" + columnName + "' not found. " + error;
        assertFalse(columnNotFoundError, index == -1);

        /* Test to see if the expected value equals the actual value (from the Cursor) */
        String expectedValue = entry.getValue().toString();
        String actualValue = valueCursor.getString(index);

        String valuesDontMatchError = "Actual value '" + actualValue
                + "' did not match the expected value '" + expectedValue + "'. "
                + error;

        assertEquals(valuesDontMatchError,
                expectedValue,
                actualValue);
    }
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:33,代码来源:TestUtilities.java

示例2: insertRequestHeaders

import android.content.ContentValues; //导入方法依赖的package包/类
/**
 * Insert request headers for a download into the DB.
 */
private void insertRequestHeaders(SQLiteDatabase db, long downloadId, ContentValues values) {
    ContentValues rowValues = new ContentValues();
    rowValues.put(Downloads.Impl.RequestHeaders.COLUMN_DOWNLOAD_ID, downloadId);
    for (Map.Entry<String, Object> entry : values.valueSet()) {
        String key = entry.getKey();
        if (key.startsWith(Downloads.Impl.RequestHeaders.INSERT_KEY_PREFIX)) {
            String headerLine = entry.getValue().toString();
            if (!headerLine.contains(":")) {
                throw new IllegalArgumentException("Invalid HTTP header line: " + headerLine);
            }
            String[] parts = headerLine.split(":", 2);
            rowValues.put(Downloads.Impl.RequestHeaders.COLUMN_HEADER, parts[0].trim());
            rowValues.put(Downloads.Impl.RequestHeaders.COLUMN_VALUE, parts[1].trim());
            db.insert(Downloads.Impl.RequestHeaders.HEADERS_DB_TABLE, null, rowValues);
        }
    }
}
 
开发者ID:redleaf2002,项目名称:downloadmanager,代码行数:21,代码来源:DownloadProvider.java

示例3: validateCurrentRecord

import android.content.ContentValues; //导入方法依赖的package包/类
static void validateCurrentRecord(String error, Cursor valueCursor, ContentValues expectedValues) {
    Set<Map.Entry<String, Object>> valueSet = expectedValues.valueSet();
    for (Map.Entry<String, Object> entry : valueSet) {
        String columnName = entry.getKey();
        int idx = valueCursor.getColumnIndex(columnName);
        assertFalse("Column '" + columnName + "' not found. " + error, idx == -1);
        String expectedValue = entry.getValue().toString();
        assertEquals("Value '" + entry.getValue().toString() +
                "' did not match the expected value '" +
                expectedValue + "'. " + error, expectedValue, valueCursor.getString(idx));
    }
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:13,代码来源:TestUtilities.java

示例4: insert

import android.content.ContentValues; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
@SuppressLint("NewApi")
@Override
public Uri insert(@NonNull Uri uri, ContentValues values) {
    switch (matcher.match(uri)) {
        case MATCH_DATA:
            SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(getContext().getApplicationContext()).edit();
            for (Entry<String, Object> entry : values.valueSet()) {
                final Object value = entry.getValue();
                final String key = entry.getKey();
                if (value == null) {
                    editor.remove(key);
                } else if (value instanceof String)
                    editor.putString(key, (String) value);
                else if (value instanceof Boolean)
                    editor.putBoolean(key, (Boolean) value);
                else if (value instanceof Long)
                    editor.putLong(key, (Long) value);
                else if (value instanceof Integer)
                    editor.putInt(key, (Integer) value);
                else if (value instanceof Float)
                    editor.putFloat(key, (Float) value);
                else {
                    throw new IllegalArgumentException("Unsupported type " + uri);
                }
            }
            editor.apply();
            break;
        default:
            throw new IllegalArgumentException("Unsupported uri " + uri);
    }

    return null;
}
 
开发者ID:riteshakya037,项目名称:Android-Scrapper,代码行数:35,代码来源:MultiProcessPreference.java


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