Android. database. SQLite. databaseobjectnotclosedexception: application did not close the cursor or da

Source: Internet
Author: User

The throwing of this exception does not cause the program to crash.

The exception information comes from the Finalize method of the sqlitedatabase class. From the exception information "close () was never explicitly called on database, application did not close the cursor or database object that was opened here
"It can be seen that this is caused by the cursor used in the program or the close of the sqlitedatabase object. That is to say, the cursor object or sqlitedatabase object created in the program is not closed after use, and the above information is displayed when they all become "junk" and are GC.

Java code
  1. @ Override
  2. Protected void finalize (){
  3. If (isopen ()){
  4. Log. E (TAG, "close () was never explicitly called on database'" +
  5. Mpath + "'", mstacktrace );
  6. Closeclosable ();
  7. Onallreferencesreleased ();
  8. }
  9. }
    @Override    protected void finalize() {        if (isOpen()) {            Log.e(TAG, "close() was never explicitly called on database '" +                    mPath + "' ", mStackTrace);            closeClosable();            onAllReferencesReleased();        }    }

To avoid such errors, remember to close () when you are not using cursor or sqlitedatabase objects (),

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.