Java tutorial
//package com.java2s; import android.database.Cursor; public class Main { /** * Checks if the passed cursor has at least 1 record. * @param cursor The {@link Cursor} to check. * @return <code>true</code> if the {@link Cursor} has at least 1 record, * <code>false</code> if not. */ public static boolean hasRecords(final Cursor cursor) { return (isOpen(cursor)) && (cursor.getCount() > 0); } /** * Checks if the passed {@link Cursor} is not null and is open. * @param cursor The {@link Cursor} to check. * @return <code>true</code> if {@link Cursor} is open, <code>false</code> if * it is closed. */ public static boolean isOpen(final Cursor cursor) { return (cursor != null) && (!cursor.isClosed()); } }