我开发了一个访问设备中数据库的应用程序;但是,我现在不知道它无法访问数据库执行代码行,如下所示:
this.productoHelper.getWritableDatabase();
这是我的异常堆栈跟踪:
01-16 19:20:04.629: E/Database(17236): CREATE TABLE android_metadata failed
01-16 19:20:04.639: E/Database(17236): Failed to setLocale() when constructing, closing the database
01-16 19:20:04.639: E/Database(17236): android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed
01-16 19:20:04.639: E/Database(17236): at android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method)
01-16 19:20:04.639: E/Database(17236): at android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:1987)
01-16 19:20:04.639: E/Database(17236): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1855)
01-16 19:20:04.639: E/Database(17236): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
01-16 19:20:04.639: E/Database(17236): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:854)
01-16 19:20:04.639: E/Database(17236): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:847)
01-16 19:20:04.639: E/Database(17236): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:550)
01-16 19:20:04.639: E/Database(17236): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
01-16 19:20:04.639: E/Database(17236): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)
01-16 19:20:04.639: E/Database(17236): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
顺便说一下!当我尝试从Eclipse Emulator执行此操作时,它运行正常但不在设备中。
答案 0 :(得分:0)
在打开数据库之前尝试使用SQLiteDatabase.NO_LOCALIZED_COLLATORS
。
答案 1 :(得分:0)
调用SQLiteDatabase.openDatabase()时只需要使用SQLiteDatabase.NO_LOCALIZED_COLLATORS标志