A SQLiteConnection object for database was leaked! Please fix your application

前端 未结 5 674
一整个雨季
一整个雨季 2020-12-15 02:37

My application give me this warning

A SQLiteConnection object for database \'+data+data+com_example_test+database\' was leaked! Please fix your ap

5条回答
  •  暖寄归人
    2020-12-15 03:30

    //Inside your SQLite helper class
    @Override
    public synchronized void close () {
        if (db != null) {
            db.close();
            super.close();
        }
    }
    
    //Inside the activity that makes a connection to the helper class
    @Override
    protected void onDestroy () {
        super.onDestroy();
        //call close() of the helper class
        dbHelper.close();
    }
    

提交回复
热议问题