Java tutorial
//package com.java2s; import android.content.ContentValues; public class Main { public static long getAsInteger(final ContentValues values, final String key, final int def) { if (values == null || key == null) return def; final Object value = values.get(key); if (value == null) return def; return Integer.valueOf(value.toString()); } }