@Manish. Jag har redigerat din exempelkod. Använd cursor.getCount() så här. Tack
public ArrayList<String> getDefinations(String query, int column_index)
{
ArrayList<String> words = new ArrayList<String>();
MatrixCursor mcursor = null;
try
{
Stmt stmt = getDB2().prepare(query);
if (stmt.step())
{
//stmt.get_cursor().moveToFirst();
mcursor = stmt.get_cursor();
if(mcursor != null && mcursor.getCount() > 0)
{
try
{
mcursor.moveToFirst();
do
{
words.add(mcursor.getString(column_index));
}
while (mcursor.moveToNext());
}
catch (IndexOutOfBoundsException e)
{
if (MainActivity.logcat_status)
{
Log.e("Error", e + "");
}
}
}
}
}
catch (Exception e)
{
// TODO Auto-generated catch block
if (MainActivity.logcat_status)
{
Log.e("Error", e + "");
}
}
}