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