-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMySQLiteOpenHelper.java
More file actions
37 lines (30 loc) · 1.16 KB
/
MySQLiteOpenHelper.java
File metadata and controls
37 lines (30 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.min.mygreendao;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import com.min.mygreendao.db.gen.DaoMaster;
import com.min.mygreendao.db.gen.TestDao;
import com.min.mygreendao.db.gen.UserDao;
import org.greenrobot.greendao.database.Database;
/**
* Created by Administrator on 2017/9/13.
*
* @des 数据库升级
*/
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);
}
}, UserDao.class,TestDao.class);//, UserDao.class
}
}