I am developing an application which has many services. When I stop the intent service, all threads and service should be stopped but the UI is hung and the following errors
Same problem also occured for me. But I am using SqLite. When I want to select List of my entity I forgot to add some important methods. When problem occured my code is following
public List getBlockeds() {
List blockeds = new ArrayList<>();
String[] allColumns = {"id", "phoneNumber"};
Cursor cursor = database.query("Blockeds", allColumns, null, null, null, null, "id desc");
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
Blocked blocked = new CursorToPojo().cursorToBlocked(cursor);
blockeds.add(blocked);
}
return blockeds;
}
When change code to following the problem solved.
public List getBlockeds() {
List blockeds = new ArrayList<>();
String[] allColumns = {"id", "phoneNumber"};
Cursor cursor = database.query("Blockeds", allColumns, null, null, null, null, "id desc");
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
Blocked blocked = new CursorToPojo().cursorToBlocked(cursor);
blockeds.add(blocked);
cursor.moveToNext();
}
cursor.close();
return blockeds;
}
I realised that when I did not use cursor.moveToNext cursor never end and the preceding problem start.