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

后端 未结 5 788
無奈伤痛
無奈伤痛 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条回答
  •  不知归路
    2020-12-16 04:35

    I am using cursor for a big query where cursor hit the DB more than 1350 times by three seperate 'QUERY' within 800 milliseconds. So I got the error (android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14)). I solved it by closing the cursor before start a new query. That resolves my problem. Hope it will work the more big query than mine.

    String data_query = "SELECT * FROM test WHERE id= " + c_id + " AND memberId = " + memberId;           
    Cursor cu_cu = userHelper.getData(data_query);
    float cu_cu_count = cu_cu.getCount();
    System.out.println("ALL ANSWER COUNT : " + cu_cu_count);
    cu_cu.close();
    

提交回复
热议问题