android中操作SQLite常见错误
来源:互联网 发布:橙树网络 编辑:程序博客网 时间:2024/06/06 20:37
最近在改应用的一些bug,想起来可以把常见错误整理下,方便自己下次更快速找出错误原因,也给遇到同样问题的同学提供解决思路。我会将错误归类,今天先写一点,以后再增加,欢迎指正。(为了不透漏一些信息,log中包名被修改了)
1. android.database.sqlite.SQLiteException: unable to close due to unfinalised statements
- 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.performLaunchActivity(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.Looper.loop(Looper.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.performLaunchActivity(ActivityThread.java:2745)
- ... 11 more
这个错误翻译过来就是:不能关闭数据库由于未完成的语句。
我从网上查了一下,最可能的原因是:你在操作sqlite数据库时使用多线程了,但sqlite数据库是不支持多线程操作,所以你必须实现多线程同步的机制。
我的程序出错是因为:在后台启动了个service定时向服务器请求数据,并在线程中将数据插入数据库。在某个时间段,用户在向数据库插入数据后,关闭数据库,而此时线程正在向数据库中写入数据,就会造成上述异常。
2.android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
- 07-04 16:18:56.677: W/System.err(29830): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
1)插入的数据有一个是主键,而且插入的主键相同;
2)插入的数据有一条数据为空,而数据库中定义不能为空,也会导致这样的错误;
- android中操作SQLite常见错误
- android中操作SQLite常见错误
- android中操作SQLite常见错误
- Android操作SQLite的几个常见方法
- Android中SQLite基本操作
- android中sqlite数据库操作
- android中SQLite的操作
- Android中SQLite数据操作
- android中SQLite简单操作
- android中SQLite数据库操作
- sqlite常见操作
- Android 中常见Bitmap操作
- SQLite数据库常见错误总结
- Android中操作Sqlite数据库:例图
- android中SQLite数据库的操作
- android中SQLite数据库的操作
- Android中使用SQlite进行数据操作
- Android中SQLite的简单crud操作
- BEC 加油!
- attempted to assign id from null one-to-one property:
- Bash中使用多行注释的方法(Here Documents)
- 英语练习77 You ought to learn swim
- C++头文件的包含顺序研究 (转)
- android中操作SQLite常见错误
- 编译内核模块的makefile
- OpenStack学习笔记————OpenStack云平台的网络模式及其工作机制
- warning: function returns address of local variable
- 如何在对话框中加入超链接
- 超前引用与命名空间
- 关闭input文本输入框的自动提示功能 设置方法
- C语言的谜题
- hdu 3336 kmp