当我使用 Galaxy tab 2 (4.0.3) 测试应用程序时出现此错误,但是当我使用 Galaxy SI (2.3.6) 和 Akai (4.0.3) 测试它时它可以工作。
我们使用了已经创建的数据库,当应用程序启动时,我会将它从助手复制到数据库目录(如果不存在)
11-20 11:20:05.170: I/SqliteDatabaseCpp(12921): sqlite returned: error code = 11, msg = database corruption at line 48112 of [ed759d5a9e], db=/data/data/com.xprts.mobilesales/databases/testDB
11-20 11:20:05.170: I/SqliteDatabaseCpp(12921): sqlite returned: error code = 11, msg = database disk image is malformed, db=/data/data/com.xprts.mobilesales/databases/testDB
11-20 11:20:05.170: E/SqliteDatabaseCpp(12921): sqlite3_exec - Failed to set synchronous mode = 1(Normal)
11-20 11:20:05.170: E/DefaultDatabaseErrorHandler(12921): Corruption reported by sqlite on database: /data/data/com.xprts.mobilesales/databases/MobileSales.DB
11-20 11:20:05.170: E/DefaultDatabaseErrorHandler(12921): deleting the database file: /data/data/com.xprts.mobilesales/databases/MobileSales.DB
11-20 11:20:05.170: I/SqliteDatabaseCpp(12921): sqlite returned: error code = 14, msg = cannot open file at line 27803 of [ed759d5a9e], db=/data/data/com.xprts.mobilesales/databases/testDB
11-20 11:20:05.170: I/SqliteDatabaseCpp(12921): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27803 - "" errno=2 path=/data/data/com.xprts.mobilesales/databases/MobileSales.DB, db=/data/data/com.xprts.mobilesales/databases/testDB
11-20 11:20:05.170: E/SqliteDatabaseCpp(12921): sqlite3_open_v2("/data/data/com.xprts.mobilesales/databases/MobileSales.DB", &handle, 2, NULL) failed
11-20 11:20:05.170: I/SqliteDatabaseCpp(12921): sqlite returned: error code = 14, msg = cannot open file at line 27803 of [ed759d5a9e], db=/data/data/com.xprts.mobilesales/databases/testDB
11-20 11:20:05.170: I/SqliteDatabaseCpp(12921): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27803 - "" errno=2 path=/data/data/com.xprts.mobilesales/databases/MobileSales.DB, db=/data/data/com.xprts.mobilesales/databases/testDB
11-20 11:20:05.170: E/SqliteDatabaseCpp(12921): sqlite3_open_v2("/data/data/com.xprts.mobilesales/databases/MobileSales.DB", &handle, 1, NULL) failed
11-20 11:20:05.178: E/SQLiteDatabase(12921): Failed to open the database. closing it.
11-20 11:20:05.178: E/SQLiteDatabase(12921): android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
11-20 11:20:05.178: E/SQLiteDatabase(12921): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
11-20 11:20:05.178: E/SQLiteDatabase(12921): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1124)
11-20 11:20:05.178: E/SQLiteDatabase(12921): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1075)
11-20 11:20:05.178: E/SQLiteDatabase(12921): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1135)
11-20 11:20:05.178: E/SQLiteDatabase(12921): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1075)
11-20 11:20:05.178: E/SQLiteDatabase(12921): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1051)
11-20 11:20:05.178: E/SQLiteDatabase(12921): at com.xprts.mobilesales.database.DBAdapter.checkDataBase(DBAdapter.java:118)
11-20 11:20:05.178: E/SQLiteDatabase(12921): at com.xprts.mobilesales.database.DBAdapter.createDataBase(DBAdapter.java:89)
11-20 11:20:05.178: E/SQLiteDatabase(12921): at com.xprts.mobilesales.database.DBAdapter.access$0(DBAdapter.java:87)
11-20 11:20:05.178: E/SQLiteDatabase(12921): at com.xprts.mobilesales.database.DBAdapter$1.run(DBAdapter.java:32)
11-20 11:20:05.178: E/SQLiteDatabase(12921): at java.lang.Thread.run(Thread.java:856)
解决方案
终于可以了,我的数据库已损坏(仅在 Galaxy Tab 2中)
CREATE TABLE [MB_DEVICE_SEQUENCES] (
[COMP_ID] TEXT(10) NOT NULL,
[DEVICE_CODE] TEXT(10) NOT NULL,
[SEQ_TYPE] TEXT(4000) DEFAULT '''10''' NOT NULL,
[COMP_YEAR] NUMERIC(4) NOT NULL,
[SEQ_CODE] TEXT(10) NOT NULL,
[DEVICE_SEQ_FROM_NUMBER] NUMERIC(20) NOT NULL,
[DEVICE_SEQ_TO_NUMBER] NUMERIC(20) NOT NULL,
[DEVICE_SEQ_INTERVAL] TEXT(20) NULL,
[DEVICE_SEQ_CONSUMED_COUNT] NUMERIC(20) NULL,
PRIMARY KEY ([COMP_ID],[DEVICE_CODE],[SEQ_TYPE],[COMP_YEAR],[SEQ_CODE],[DEVICE_SEQ_FROM_NUMBER])
)