-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
使用不加密的数据库,以避免sqlsipher在低版本崩溃问题,以及旧数据迁移
- Loading branch information
Showing
4 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
accountcache/src/main/java/com/hss01248/accountcache/MySQLiteUpgradeOpenHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.hss01248.accountcache; | ||
|
||
import android.content.Context; | ||
import android.database.sqlite.SQLiteDatabase; | ||
|
||
import com.github.yuweiguocn.library.greendao.MigrationHelper; | ||
import com.hss01248.accountcache.db.DaoMaster; | ||
import com.hss01248.accountcache.db.DebugAccountDao; | ||
|
||
|
||
import org.greenrobot.greendao.database.Database; | ||
|
||
public class MySQLiteUpgradeOpenHelper extends DaoMaster.OpenHelper { | ||
public MySQLiteUpgradeOpenHelper(Context context, String name) { | ||
super(context, name); | ||
} | ||
|
||
public MySQLiteUpgradeOpenHelper(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); | ||
} | ||
}, DebugAccountDao.class); | ||
} | ||
} |