Java tutorial
//package com.java2s; import android.database.Cursor; public class Main { public static float getCursorFloat(Cursor cursor, String name) { if (isCursorEmpty(cursor)) { return 0; } else { return cursor.getFloat(cursor.getColumnIndex(name)); } } public static boolean isCursorEmpty(Cursor cursor) { return (cursor == null || cursor.isClosed() || cursor.getCount() == 0); } }