Android java. Lang. illegalstateexception: Database not open solution

Source: Internet
Author: User

07-12 07:34:04. 411: Warn/system. Err (533): Java. Lang. illegalstateexception: Database not open
07-12 07:34:04. 440: Warn/system. Err (533): At android.database.sqlite.sqlitedatabase.exe csql (sqlitedatabase. Java: 1759)

These two rows are error messages

OnCode. However, database not open is reported this time. This problem has not occurred before.

After checking, I found that I first dropped the query in a method and then executed the create operation. In the method, I operated the database twice in total.

The getwritabledatabase method is used at one time, and the getreadabledatabase method is used at one time.

After the query, I disabled the sqlitedatabase obtained by getreadabledatabase,

As a result, this operation directly affects the sqlitedatabase obtained by getwritabledatabase.

 

Solution: Put the statement of sqlitedatabase obtained through getwritabledatabase after the query!

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.