赞
踩
最近在做apk升级的时候数据库方出现了如标题一样的问题,一直没找到问题所在,请各位知情人士帮个忙。
大概是这样我做了一个应用,需要版本升级,升级的时候应用所用的数据库表字段有所修改,同事增加了新的表,在升级的时候我增加了数据库的版本号,
随后升级之后打开应用程序就会出现这样的错我,自我分析可能是权限问题,但是我是一个相同的应用所以这个不知道是不是正确。下面是执行的代码和
异常信息。
代码:
@Override public void onCreate(SQLiteDatabase db) { // 执行建表语句 try { db.execSQL(DBCommon.CREATE_TABLE_GAMETYPE); db.execSQL(DBCommon.CREATE_TABLE_GAMELIST); db.execSQL(DBCommon.CREATE_TABLE_ADS); db.execSQL(DBCommon.CREATE_TABLE_BUYLIST); db.execSQL(DBCommon.CREATE_TABLE_MOBILECONTROL); db.execSQL(DBCommon.CREATE_TABLE_DOWNLOAD); } catch (Exception e) { e.printStackTrace(); LOG.d(DBG, TAG, "creat table Exception:" + e); } LOG.d(DBG, TAG, "SQLiteDatabase onCreate"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { LOG.d(DBG, TAG, "SQLiteDatabase onUpgrade"); db.execSQL("DROP TABLE IF EXISTS " + DBCommon.TABLE_GAMETYPE); db.execSQL("DROP TABLE IF EXISTS " + DBCommon.TABLE_GAMELIST); db.execSQL("DROP TABLE IF EXISTS " + DBCommon.TABLE_ADS); db.execSQL("DROP TABLE IF EXISTS " + DBCommon.TABLE_BUYLIST); db.execSQL("DROP TABLE IF EXISTS " + DBCommon.TABLE_MOBILECONTROL); db.execSQL("DROP TABLE IF EXISTS " + DBCommon.TABLE_DOWNLOADE); onCreate(db); }
异常信息:
08-16 15:41:20.795: I/SqliteDatabaseCpp(26920): sqlite returned: error code = 14, msg = cannot open file at line 27699 of [8609a15dfa], db=/data/data/com.andlisoft.station.game/databases/station.db 08-16 15:41:20.795: I/SqliteDatabaseCpp(26920): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27699 - "" errno=13 path=/data/data/com.andlisoft.station.game/databases/station.db, db=/data/data/com.andlisoft.station.game/databases/station.db 08-16 15:41:20.795: E/SqliteDatabaseCpp(26920): sqlite3_open_v2("/data/data/com.andlisoft.station.game/databases/station.db", &handle, 6, NULL) failed 08-16 15:41:20.945: I/ALSAModule(1868): Terminated ALSA PLAYBACK device hifi 08-16 15:41:20.980: E/SQLiteDatabase(26920): Failed to open the database. closing it. 08-16 15:41:20.980: E/SQLiteDatabase(26920): android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1013) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:986) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1051) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:802) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:157) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at com.andlisoft.station.game.db.GameTypeDBControl.query(GameTypeDBControl.java:122) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at com.andlisoft.station.game.model.GameTypeModel.getGameTypeByName(GameTypeModel.java:103) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at com.andlisoft.station.game.appwidget.WidgetGetData.getData(WidgetGetData.java:26) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at com.andlisoft.station.game.appwidget.MainWidget.onReceive(MainWidget.java:120) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2242) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.app.ActivityThread.access$1500(ActivityThread.java:132) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.os.Handler.dispatchMessage(Handler.java:99) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.os.Looper.loop(Looper.java:137) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at android.app.ActivityThread.main(ActivityThread.java:4575) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at java.lang.reflect.Method.invokeNative(Native Method) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at java.lang.reflect.Method.invoke(Method.java:511) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) 08-16 15:41:20.980: E/SQLiteDatabase(26920): at dalvik.system.NativeStart.main(Native Method) 08-16 15:41:20.980: W/System.err(26920): android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file 08-16 15:41:20.980: W/System.err(26920): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method) 08-16 15:41:20.980: W/System.err(26920): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1013) 08-16 15:41:20.980: W/System.err(26920): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:986) 08-16 15:41:20.980: W/System.err(26920): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1051) 08-16 15:41:20.980: W/System.err(26920): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:802) 08-16 15:41:20.980: W/System.err(26920): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221) 08-16 15:41:20.980: W/System.err(26920): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221) 08-16 15:41:20.980: W/System.err(26920): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:157) 08-16 15:41:20.980: W/System.err(26920): at com.andlisoft.station.game.db.GameTypeDBControl.query(GameTypeDBControl.java:122) 08-16 15:41:20.980: W/System.err(26920): at com.andlisoft.station.game.model.GameTypeModel.getGameTypeByName(GameTypeModel.java:103) 08-16 15:41:20.980: W/System.err(26920): at com.andlisoft.station.game.appwidget.WidgetGetData.getData(WidgetGetData.java:26) 08-16 15:41:20.980: W/System.err(26920): at com.andlisoft.station.game.appwidget.MainWidget.onReceive(MainWidget.java:120) 08-16 15:41:20.980: W/System.err(26920): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2242) 08-16 15:41:20.980: W/System.err(26920): at android.app.ActivityThread.access$1500(ActivityThread.java:132) 08-16 15:41:20.980: W/System.err(26920): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207) 08-16 15:41:20.980: W/System.err(26920): at android.os.Handler.dispatchMessage(Handler.java:99) 08-16 15:41:20.980: W/System.err(26920): at android.os.Looper.loop(Looper.java:137) 08-16 15:41:20.980: W/System.err(26920): at android.app.ActivityThread.main(ActivityThread.java:4575) 08-16 15:41:20.980: W/System.err(26920): at java.lang.reflect.Method.invokeNative(Native Method) 08-16 15:41:20.980: W/System.err(26920): at java.lang.reflect.Method.invoke(Method.java:511) 08-16 15:41:20.980: W/System.err(26920): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 08-16 15:41:20.980: W/System.err(26920): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) 08-16 15:41:20.980: W/System.err(26920): at dalvik.system.NativeStart.main(Native Method) 08-16 15:41:20.980: E/ZQ_17StationGame_GameTypeDBControl(26920): android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
还请大家多多帮助。
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。