Normaly, this code working very well. But, if \"cursor\" is empty, there is an error in main.class. I tried a lot of thing. But, I didn\'t success. Please help to solve way.
If the cursor contains no data, moveToFirst()
returns false. So add any special empty cursor handling to an else
branch of your if (cursor.moveToFirst())
conditional in your first snippet:
if (cursor.moveToFirst()) {
do {
list.add(Integer.parseInt(cursor.getString(1)));
}
while (cursor.moveToNext());
} else {
// whatever you'd like to do in case of no data
}