05-12 18:51:14. 676: E/androidruntime (22729): Java. Lang. illegalstateexception: Database not open
05-12 18:51:14. 676: E/androidruntime (22729): at Android. database. SQLite. sqlitedatabase. insertwithonconflict (sqlitedatabase. Java: 1526)
05-12 18:51:14. 676: E/androidruntime (22729): At com. ailk. DB. netdb. addnetappflow (netdb. Java: 391)
05-12 18:51:14. 676: E/androidruntime (22729): At com. ailk. Android. sjb. mysmsservice. getapptrafficlist (mysmsservice. Java: 458)
05-12 18:51:14. 676: E/androidruntime (22729): At com. ailk. Android. sjb. mysmsservice. recordflow (mysmsservice. Java: 138)
05-12 18:51:14. 676: E/androidruntime (22729): At com. ailk. Android. sjb. mysmsservice $ 3.run( mysmsservice. Java: 122)
05-12 18:51:14. 676: E/androidruntime (22729): At java. Lang. thread. Run (thread. Java: 1019)
05-12 18:54:29. 246: E/androidruntime (27041): Fatal exception: thread-13
05-12 18:54:29. 246: E/androidruntime (27041): Java. Lang. nullpointerexception
05-12 18:54:29. 246: E/androidruntime (27041): At com. ailk. Android. sjb. mysmsservice. getapptrafficlist (mysmsservice. Java: 478)
05-12 18:54:29. 246: E/androidruntime (27041): At com. ailk. Android. sjb. mysmsservice. recordflow (mysmsservice. Java: 138)
05-12 18:54:29. 246: E/androidruntime (27041): At com. ailk. Android. sjb. mysmsservice $ 3.run( mysmsservice. Java: 122)
05-12 18:54:29. 246: E/androidruntime (27041): At java. Lang. thread. Run (thread. Java: 1019)
05-12 18:58:17. 796: E/androidruntime (28654): Fatal exception: thread-16
05-12 18:58:17. 796: E/androidruntime (28654): Java. Lang. nullpointerexception
05-12 18:58:17. 796: E/androidruntime (28654): At com. ailk. Android. sjb. mysmsservice. getapptrafficlist (mysmsservice. Java: 478)
05-12 18:58:17. 796: E/androidruntime (28654): At com. ailk. Android. sjb. mysmsservice. recordflow (mysmsservice. Java: 138)
05-12 18:58:17. 796: E/androidruntime (28654): At com. ailk. Android. sjb. mysmsservice $ 3.run( mysmsservice. Java: 122)
05-12 18:58:17. 796: E/androidruntime (28654): At java. Lang. thread. Run (thread. Java: 1019)
Method {
Sqlitedatabase DB = getreadabledatabase ();
...
DB. Close ();
}
Incorrect practice:
Method B (){
Sqlitedatabase
DB = getreadabledatabase ();
Call method ();
DB. insert and other operations report error
}
Correct practice:
Method B (){
Call method ();
Sqlitedatabase DB = getreadabledatabase ();
DB. insert and other operations report error
}
Note: If the database is disabled, an error is returned!
TIPS:
Getreadabledatabase () is not used to open the database in read-only mode. Instead, getwritabledatabase () is executed first. It is called only when a failure occurs.
Both the getwritabledatabase () and getreadabledatabase () methods can obtain a sqlitedatabase instance used to operate the database.
However, the getwritabledatabase () method opens the database in read/write mode. Once the disk space of the database is full, the database can only read but cannot write,
An error occurs when getwritabledatabase () is opened to the database. The getreadabledatabase () method first opens the database in read/write mode,
If the disk space of the database is full, the database will fail to be opened. If the disk space of the database fails to be opened, the database will continue to be opened in read-only mode.