public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { Logger.dLog( TAG, "=============== upgrade database" + "oldVersion is:" + oldVersion + "newVersion is:" + newVersion + "DATABASE_VERSION is:" + DATABASE_VERSION); upgradeBookTable(db, oldVersion, newVersion); upgradeBookMarkTable(db, oldVersion, newVersion); }
// modify by zenki-zha-xxx static { IEngineService ies = (IEngineService) ERManager.getService(ERManager.ERENGINE_SERVICE); String libPath = ies.getConfig().getLibraryPath(); String soPath = libPath + File.separator + "libDeflatingDecompressor-v3.so"; try { if (libPath.equals(EngineConfig.DEFAULT_LIBRARY_LOCAL)) { System.loadLibrary("DeflatingDecompressor-v3"); } else { System.load(soPath); } } catch (Exception e) { Logger.eLog("EREngine", "load libDeflatingDecompressor-v3.so = " + e.getMessage()); } }
private void createBookTable(SQLiteDatabase db) { String createString; String bookColumns; bookColumns = BookColumns.FILE_PATH + " TEXT, " + BookColumns.FILE_NAME + " TEXT, " + BookColumns.FILE_TYPE + " TEXT ," + BookColumns.LAST_LOCATION + " TEXT, " + BookColumns.LAST_PAGE_NUM + " INTEGER, " + BookColumns.TOTAL_PAGE_NUM + " INTEGER, " + BookColumns.LAST_ACCESS_TIME + " BIGINT, " + BookColumns.META_TITLE + " TEXT, " + BookColumns.META_AUTHOR + " TEXT, " + BookColumns.META_PUBLISHER + " TEXT, " + BookColumns.META_ENCODING + " TEXT, " + BookColumns.META_LANGUAGE + " TEXT, " + BookColumns.USER_NAME + " TEXT, " + BookColumns.PASSWORD + " TEXT, " + BookColumns.VIEW_WIDTH + " INTEGER, " + BookColumns.VIEW_HEIGHT + " INTEGER, " + BookColumns.FONT_LEVEL + " INTEGER, " + BookColumns.FILE_SIZE + " INTEGER " + ");"; createString = " (" + BookColumns._ID + " integer primary key autoincrement, " + bookColumns; db.execSQL("create table " + BOOKINFO_TABLE_NAME + createString); // set index String indexColumns[] = {BookColumns.FILE_PATH, BookColumns.FILE_NAME, BookColumns.META_AUTHOR}; // add index to book table for (String columnName : indexColumns) { db.execSQL(createIndex(BOOKINFO_TABLE_NAME, columnName)); } // add trigger to book table // when book delete, in bookMark table,bookMark.book_id = book._id this // record is delete try { db.execSQL( "CREATE TRIGGER delete_book_table_trigger AFTER DELETE ON " + BOOKINFO_TABLE_NAME + " for each row BEGIN " + " DELETE FROM " + BOOKMARK_TABLE_NAME + " WHERE book_id = OLD._id;" + " END;"); db.execSQL( "CREATE TRIGGER delete_book_table_trigger2 AFTER DELETE ON " + BOOKINFO_TABLE_NAME + " for each row BEGIN " + " DELETE FROM " + BOOKEMPHASIS_TABLE_NAME + " WHERE book_id = OLD._id;" + " END;"); } catch (SQLException e) { Logger.eLog(TAG, "create trigger exception = " + e); } }