I have following class \"Singleton\" to handle SQLite connection and to make sure to have 1 instance of connection for whole process/app:
public class DBCon
before executing any query to this stuff (You should open your database). Close db after completion the task.
private DBHelper dbHelper = new DBHelper(context);
try {
_db = dbHelper.getWritableDatabase();
} catch (SQLException s) {
new Exception("Error with DB Open");
}
// Then write your query now.... and then close the db.
_db.close();
You can check out my git link1 git link2