Some bugs are being modified recently. If you think of them, you can sort out common errors so that you can quickly find out the cause of the error more quickly next time and provide solutions for those who encounter the same problem. I will classify the errors. I will write a little bit today and then add them later. please correct me. (In order not to disclose some information, the name of the log package has been modified)
1.Android. database. SQLite. sqliteexception: unable to close due to unfinalised statements
[Java]
View plaincopy
- Fatal exception: Main
- Java. Lang. runtimeexception: unable to start activity componentinfo {com. Evaluation/COM. Evaluation. vehicleactivity}: Android. database. SQLite. sqliteexception: unable to close due to unfinalised statements
- At Android. App. activitythread. javasmlaunchactivity (activitythread. Java: 2781)
- At Android. App. activitythread. handlelaunchactivity (activitythread. Java: 2797)
- At Android. App. activitythread. Access $2300 (activitythread. Java: 135)
- At Android. App. activitythread $ H. handlemessage (activitythread. Java: 2132)
- At Android. OS. handler. dispatchmessage (handler. Java: 99)
- At Android. OS. lorule. Loop (lorule. Java: 143)
- At Android. App. activitythread. Main (activitythread. Java: 4914)
- At java. Lang. Reflect. method. invokenative (native method)
- At java. Lang. Reflect. method. Invoke (method. Java: 521)
- At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 868)
- At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 626)
- At Dalvik. system. nativestart. Main (native method)
- Caused by: Android. database. SQLite. sqliteexception: unable to close due to unfinalised statements
- At Android. database. SQLite. sqlitedatabase. dbclose (native method)
- At Android. database. SQLite. sqlitedatabase. onallreferencesreleased (sqlitedatabase. Java: 363)
- At Android. database. SQLite. sqliteclosable. releasereference (sqliteclosable. Java: 45)
- At Android. database. SQLite. sqliteprogram. onallreferencesreleased (sqliteprogram. Java: 116)
- At Android. database. SQLite. sqliteclosable. releasereference (sqliteclosable. Java: 45)
- At Android. database. SQLite. sqliteprogram. Close (sqliteprogram. Java: 293)
- At Android. database. SQLite. sqlitequery. Close (sqlitequery. Java: 133)
- At Android. database. SQLite. sqlitecursor. Close (sqlitecursor. Java: 532)
- At com. databasehelper. selectassessinformation (databasehelper. Java: 338)
- At com. jskapplication. selectassessinformation (jskapplication. Java: 631)
- At com. vehicleactivity. oncreate (vehicleactivity. Java: 548)
- At Android. App. instrumentation. callactivityoncreate (instrumentation. Java: 1065)
- At Android. App. activitythread. javasmlaunchactivity (activitythread. Java: 2745)
- ... 11 more
This error is translated as: the database cannot be closed due to incomplete statements.
I checked it online. The most likely reason is that you have used multithreading when operating the SQLite database, but the SQLite database does not support multithreading, therefore, you must implement multi-threaded synchronization.
My program failed because I started a service in the background to request data from the server and insert data into the database in the thread. During a certain period of time, when a user inserts data into the database and closes the database, the thread is writing data to the database, which will cause the above exception.
2.Android. database. SQLite. sqliteconstraintexception: Error Code 19: constraint failed
[Java]
View plaincopy
- 07-04 16:18:56. 677: W/system. Err (29830): Android. database. SQLite. sqliteconstraintexception: Error Code 19: constraint failed
Constraints failed, causing such errors. Generally, there are two reasons:
1) One of the inserted data is the primary key, and the inserted primary key is the same;
2) if one piece of inserted data is empty and the database definition cannot be empty, this will also lead to such an error;
Some bugs are being modified recently. If you think of them, you can sort out common errors so that you can quickly find out the cause of the error more quickly next time and provide solutions for those who encounter the same problem. I will classify the errors. I will write a little bit today and then add them later. please correct me. (In order not to disclose some information, the name of the log package has been modified)
1.Android. database. SQLite. sqliteexception: unable to close due to unfinalised statements
[Java]
View plaincopy
- Fatal exception: Main
- Java. Lang. runtimeexception: unable to start activity componentinfo {com. Evaluation/COM. Evaluation. vehicleactivity}: Android. database. SQLite. sqliteexception: unable to close due to unfinalised statements
- At Android. App. activitythread. javasmlaunchactivity (activitythread. Java: 2781)
- At Android. App. activitythread. handlelaunchactivity (activitythread. Java: 2797)
- At Android. App. activitythread. Access $2300 (activitythread. Java: 135)
- At Android. App. activitythread $ H. handlemessage (activitythread. Java: 2132)
- At Android. OS. handler. dispatchmessage (handler. Java: 99)
- At Android. OS. lorule. Loop (lorule. Java: 143)
- At Android. App. activitythread. Main (activitythread. Java: 4914)
- At java. Lang. Reflect. method. invokenative (native method)
- At java. Lang. Reflect. method. Invoke (method. Java: 521)
- At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 868)
- At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 626)
- At Dalvik. system. nativestart. Main (native method)
- Caused by: Android. database. SQLite. sqliteexception: unable to close due to unfinalised statements
- At Android. database. SQLite. sqlitedatabase. dbclose (native method)
- At Android. database. SQLite. sqlitedatabase. onallreferencesreleased (sqlitedatabase. Java: 363)
- At Android. database. SQLite. sqliteclosable. releasereference (sqliteclosable. Java: 45)
- At Android. database. SQLite. sqliteprogram. onallreferencesreleased (sqliteprogram. Java: 116)
- At Android. database. SQLite. sqliteclosable. releasereference (sqliteclosable. Java: 45)
- At Android. database. SQLite. sqliteprogram. Close (sqliteprogram. Java: 293)
- At Android. database. SQLite. sqlitequery. Close (sqlitequery. Java: 133)
- At Android. database. SQLite. sqlitecursor. Close (sqlitecursor. Java: 532)
- At com. databasehelper. selectassessinformation (databasehelper. Java: 338)
- At com. jskapplication. selectassessinformation (jskapplication. Java: 631)
- At com. vehicleactivity. oncreate (vehicleactivity. Java: 548)
- At Android. App. instrumentation. callactivityoncreate (instrumentation. Java: 1065)
- At Android. App. activitythread. javasmlaunchactivity (activitythread. Java: 2745)
- ... 11 more
This error is translated as: the database cannot be closed due to incomplete statements.
I checked it online. The most likely reason is that you have used multithreading when operating the SQLite database, but the SQLite database does not support multithreading, therefore, you must implement multi-threaded synchronization.
My program failed because I started a service in the background to request data from the server and insert data into the database in the thread. During a certain period of time, when a user inserts data into the database and closes the database, the thread is writing data to the database, which will cause the above exception.
2.Android. database. SQLite. sqliteconstraintexception: Error Code 19: constraint failed
[Java]
View plaincopy
- 07-04 16:18:56. 677: W/system. Err (29830): Android. database. SQLite. sqliteconstraintexception: Error Code 19: constraint failed
Constraints failed, causing such errors. Generally, there are two reasons:
1) One of the inserted data is the primary key, and the inserted primary key is the same;
2) if one piece of inserted data is empty and the database definition cannot be empty, this will also lead to such an error;