Android Sqlite Error android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file-ThrowExceptions

Exception or error:

I have this error when I test app with Galaxy tab 2 (4.0.3)
but when I test it with Galaxy SI (2.3.6) and Akai (4.0.3) it’s works.

We used database already created ,when application is started I will copy it from assists to database directory (if not exist )

 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)

Solution


finally it’s works
my database is corrupted (just in Galaxy Tab 2)
I have tried SQLJet Database Browser to check my DataBase
the error is (DEFAULT ”’10”’) in this sql statement
now it’s work good, thanks

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])
)
How to solve:

Make sure that the file copy is completed successfully, your database is corrupted after the copy.

It could also be that you don’t have the necessary meta data on your pre-existing database.
Did you follow the steps in here ?

Leave a Reply

Your email address will not be published. Required fields are marked *