Closing the SQLiteDatabase in a Content Provider

╄→尐↘猪︶ㄣ 提交于 2019-12-10 20:19:10

问题


I'm looking through the NotePad example that comes with the Android SDK and I was wondering if someone could clarify why the the variable db is never closed in the update function? It's usually a good idea to close the database when it is no longer in use to prevent leaks. Ideas?

    @Override
    public int update(Uri uri, ContentValues values, String where, String[] whereArgs) {

        // Opens the database object in "write" mode.
        SQLiteDatabase db = mOpenHelper.getWritableDatabase();

        ... // More code, db.close() is never called?!

        // Returns the number of rows updated.
        return count;
    }

来源:https://stackoverflow.com/questions/14267176/closing-the-sqlitedatabase-in-a-content-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!