當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。