SQLite unable to open database file (code 14) on frequent “SELECT” query

后端 未结 5 786
無奈伤痛
無奈伤痛 2020-12-16 04:09

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         


        
5条回答
  •  旧时难觅i
    2020-12-16 04:43

    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

提交回复
热议问题