Android 2.3.3
Eclipse Version: 3.7.0
LogCat
LogCat 报错信息:
02-13 09:21:35.030: WARN/dalvikvm(17173): threadid=19: thread exiting with uncaught exception (group=0x40015560)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): FATAL EXCEPTION: Thread-26
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x309b08
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at android.database.sqlite.SQLiteProgram.native_bind_string(Native Method)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:244)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at android.database.sqlite.SQLiteQuery.bindString(SQLiteQuery.java:185)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:48)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1235)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1189)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1271)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at com.tmall.nokia.db.RecordDBHelper.query(RecordDBHelper.java:50)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at com.tmall.nokia.manage.RecordDBopt.get(RecordDBopt.java:78)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at com.tmall.nokia.manage.RecordMessage.sendMseeage(RecordMessage.java:111)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at com.tmall.nokia.manage.RecordMessage.sendMseeage(RecordMessage.java:87)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at com.tmall.nokia.Report.run(Report.java:49)
02-13 09:21:35.130: ERROR/AndroidRuntime(17173): at java.lang.Thread.run(Thread.java:1019)
02-13 09:21:35.200: WARN/ActivityManager(62): Force finishing activity com.tmall.nokia/.Iphone
发生错误原因分析:
此处at com.tmall.nokia.db.RecordDBHelper.query(RecordDBHelper.java:50)出现问题:
Cursor cur = db.query(TBL_NAME, null, where, args, null, null, order);
按照错误Log提示,继续查找出错位置,发现传入参数where和args数组长度不一致。因此报错“android.database.sqlite.SQLiteException: bind or column index out of range”(绑定或列的索引超出范围)。
解决办法:
找到出错原因后,修改传入参数,保证传入参数where 与args长度一致。