insert Content Values to ContentValues - Android android.content

Android examples for android.content:ContentValues

Description

insert Content Values to ContentValues

Demo Code


//package com.java2s;
import android.content.ContentValues;

public class Main {
    public final static String COLUMN_PREFIX = "tbl_";

    public static void insertContentValues(ContentValues values,
            String key, Object object) {
        String columnName = new StringBuffer(COLUMN_PREFIX).append(key)
                .toString();//from   w ww. j a va 2  s  .c o m
        if (object instanceof String) {
            values.put(columnName, (String) object);
        }
        if (object instanceof Boolean) {
            values.put(columnName, (Boolean) object);
        } else if (object instanceof Integer) {
            values.put(columnName, (Integer) object);
        } else if (object instanceof Long) {
            values.put(columnName, (Long) object);
        } else if (object instanceof Float) {
            values.put(columnName, (Float) object);
        } else if (object instanceof Double) {
            values.put(columnName, (Double) object);
        }
    }
}

Related Tutorials