Remove
db.close();
If you try another operation after closing the database, it will give you that exception.
The documentation says:
Releases a reference to the object, closing the object…
Also, check out
Android SQLite closed exception about a comment from an Android Framework engineer which states that it is not necessary to close the database connection, however this is only when it is managed in a ContentProvider
.