Android examples for android.content:ContentValues
copy ContentValues
//package com.java2s; import android.content.ContentValues; import java.util.List; public class Main { public static void copyContentValues(ContentValues src, ContentValues dest, List<String> keys) { for (String field : keys) { Object value = src.get(field); if (value == null) { dest.putNull(field);/*from w w w . j av a2 s . com*/ } else if (value instanceof String) { dest.put(field, (String) value); } else if (value instanceof Integer) { dest.put(field, (Integer) value); } else if (value instanceof Boolean) { dest.put(field, (Boolean) value); } else if (value instanceof Long) { dest.put(field, (Long) value); } else if (value instanceof Float) { dest.put(field, (Float) value); } else { throw new RuntimeException("Value for field (" + field + ") has unknown type"); } } } }