我的應用程序的部分活用戶遇到SQLite數據庫損壞。當我們收集的日誌從用戶,我們發現如下信息:如何使用DefaultDatabaseErrorHandler處理Android中的數據庫損壞
E/SQLiteLog(14085): (11) database corruption at line 57189 of [b3bb660af9]
E/SQLiteLog(14085): (11) Invalid page count: nPage: 52, nPageFile: 50
E/SQLiteLog(14085): (11) lockBtree() error, rc: 11, printing out first page (size: 32768) of DB /data/data/com.app.testpackagename/files//db/statictext_v3.0_DE.db
E/SQLiteLog(14085): (11) Page (1) has been corrupted
E/SQLiteLog(13318): (11) database disk image is malformed
E/DefaultDatabaseErrorHandler(13318): Corruption reported by sqlite on database: /data/data/com.app.testpackagename/files//db/statictext_v3.0_DE.db
E/SQLiteLog(13318): (11) database corruption at line 57189 of [b3bb660af9]
E/SQLiteLog(13318): (11) Invalid page count: nPage: 52, nPageFile: 50
E/SQLiteLog(13318): (11) lockBtree() error, rc: 11, printing out first page (size: 32768) of DB /data/data/com.app.testpackagename/files//db/statictext_v3.0_DE.db
E/SQLiteLog(13318): (11) Page (1) has been corrupted
腐敗的數據庫是靜態數據庫(已預裝記錄,我們沒有做任何插入,更新,阿爾特 ,刪除除了從中選擇數據。
這個數據庫是在我的應用程序的資產,我也安裝到設備,並獲取其Ø與
this.staticDb = SQLiteDatabase.openDatabase(AppDelegate.getFileDirectory() + "/" + SDCARD_FOLDER_NAME +DB_FOLDER_NAME + "/" + Dbpath, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
我想使用這個類的onCorruption
方法,但沒有得到實施任何適當的文件來處理這個異常與DefaultDatabaseErrorHandler bject。我能用這個課程嗎?
謝謝,我會嘗試這一點。 –
它適用於我,但需要'SQLiteDatabase.OPEN_READWRITE'而不是'SQLiteDatabase.OPEN_READONLY' –
取決於您想與數據庫建立什麼樣的連接 – Dibzmania