Android examples for Database:Cursor Get
get Datum from Cursor
//package com.java2s; import android.database.Cursor; public class Main { public static Object getDatum(Cursor cursor, String column) { int index = cursor.getColumnIndex(column); return getDatum(cursor, index); }/* ww w . j ava 2 s . c o m*/ public static Object getDatum(Cursor cursor, int index) { int type = cursor.getType(index); Object data; switch (type) { case Cursor.FIELD_TYPE_STRING: data = cursor.getString(index); break; case Cursor.FIELD_TYPE_INTEGER: // Because INTEGER can store Long and Integer, we need to use Long, and cast later data = cursor.getLong(index); break; case Cursor.FIELD_TYPE_FLOAT: data = cursor.getDouble(index); break; default: data = null; break; } return data; } }