### MySQLiteOpenHelper Example Source: https://github.com/yuweiguocn/greendaoupgradehelper/blob/master/README.md Example of a custom MySQLiteOpenHelper class that extends DaoMaster.OpenHelper and utilizes MigrationHelper for database upgrades. ```java public class MySQLiteOpenHelper extends DaoMaster.OpenHelper { public MySQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) { super(context, name, factory); } @Override public void onUpgrade(Database db, int oldVersion, int newVersion) { MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() { @Override public void onCreateAllTables(Database db, boolean ifNotExists) { DaoMaster.createAllTables(db, ifNotExists); } @Override public void onDropAllTables(Database db, boolean ifExists) { DaoMaster.dropAllTables(db, ifExists); } },TestDataDao.class, TestData2Dao.class, TestData3Dao.class); } } ``` -------------------------------- ### Complete MySQLiteOpenHelper Class Source: https://github.com/yuweiguocn/greendaoupgradehelper/blob/master/README_CH.md This is a complete example of a custom SQLiteOpenHelper class that integrates GreenDaoUpgradeHelper for database migrations. ```java public class MySQLiteOpenHelper extends DaoMaster.OpenHelper { public MySQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) { super(context, name, factory); } @Override public void onUpgrade(Database db, int oldVersion, int newVersion) { MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() { @Override public void onCreateAllTables(Database db, boolean ifNotExists) { DaoMaster.createAllTables(db, ifNotExists); } @Override public void onDropAllTables(Database db, boolean ifExists) { DaoMaster.dropAllTables(db, ifExists); } },TestDataDao.class, TestData2Dao.class, TestData3Dao.class); } } ``` -------------------------------- ### Initialize DaoMaster with Custom Helper Source: https://github.com/yuweiguocn/greendaoupgradehelper/blob/master/README.md Initialize the DaoMaster with a custom SQLiteOpenHelper instance to enable database upgrade functionality. ```java //MigrationHelper.DEBUG = true; //if you want see the log info,default is false MySQLiteOpenHelper helper = new MySQLiteOpenHelper(this, "test.db", null); daoMaster = new DaoMaster(helper.getWritableDatabase()); ``` -------------------------------- ### Implement Database Upgrade Logic Source: https://github.com/yuweiguocn/greendaoupgradehelper/blob/master/README_CH.md Create a new class extending DaoMaster.OpenHelper and implement the onUpgrade method to handle database migrations using MigrationHelper. Provide all your Dao classes as arguments. ```java MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() { @Override public void onCreateAllTables(Database db, boolean ifNotExists) { DaoMaster.createAllTables(db, ifNotExists); } @Override public void onDropAllTables(Database db, boolean ifExists) { DaoMaster.dropAllTables(db, ifExists); } },TestDataDao.class, TestData2Dao.class, TestData3Dao.class); ``` -------------------------------- ### Initialize GreenDao Master Source: https://github.com/yuweiguocn/greendaoupgradehelper/blob/master/README_CH.md Initialize the DaoMaster with your custom SQLiteOpenHelper. Set MigrationHelper.DEBUG to true to view log information. ```java //MigrationHelper.DEBUG = true; //如果你想查看日志信息,请将DEBUG设置为true MySQLiteOpenHelper helper = new MySQLiteOpenHelper(this, "test.db", null); daoMaster = new DaoMaster(helper.getWritableDatabase()); ``` -------------------------------- ### Add Jitpack Repository to Gradle Source: https://github.com/yuweiguocn/greendaoupgradehelper/blob/master/README_CH.md Add the Jitpack repository to your root-level build.gradle file to include the GreenDaoUpgradeHelper library. ```gradle allprojects { repositories { ... maven { url "https://jitpack.io" } } } ``` -------------------------------- ### ProGuard Configuration for GreenDao Source: https://github.com/yuweiguocn/greendaoupgradehelper/blob/master/README_CH.md Add these ProGuard rules to your proguard-rules.pro file to ensure proper functioning of GreenDao with obfuscation. ```java -keepclassmembers class * extends org.greenrobot.greendao.AbstractDao { public static void dropTable(org.greenrobot.greendao.database.Database, boolean); public static void createTable(org.greenrobot.greendao.database.Database, boolean); } ``` -------------------------------- ### Add GreenDaoUpgradeHelper Dependency (GreenDao 3.0 below) Source: https://github.com/yuweiguocn/greendaoupgradehelper/blob/master/README.md Include the GreenDaoUpgradeHelper dependency for greenDao versions below 3.0. ```gradle dependencies { compile 'de.greenrobot:greendao:2.0.0' compile 'com.github.yuweiguocn:GreenDaoUpgradeHelper:v1.0.1' } ``` -------------------------------- ### Add GreenDaoUpgradeHelper Dependency (GreenDao < 3.0) Source: https://github.com/yuweiguocn/greendaoupgradehelper/blob/master/README_CH.md Use this dependency for older versions of GreenDao (prior to 3.0). ```gradle dependencies { compile 'de.greenrobot:greendao:2.0.0' compile 'com.github.yuweiguocn:GreenDaoUpgradeHelper:v1.0.1' } ``` -------------------------------- ### Add GreenDaoUpgradeHelper Dependency (GreenDao 3.0+) Source: https://github.com/yuweiguocn/greendaoupgradehelper/blob/master/README_CH.md Include the GreenDaoUpgradeHelper dependency in your app-level build.gradle file for GreenDao versions 3.0 and above. ```gradle dependencies { compile 'org.greenrobot:greendao:3.2.0' compile 'io.github.yuweiguocn:GreenDaoUpgradeHelper:v2.2.1' } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.