diff --git a/DaoGenerator/src/main/java/orz/sorz/lab/smallcloudemoji/daogenerator/AppDaoGenerator.java b/DaoGenerator/src/main/java/orz/sorz/lab/smallcloudemoji/daogenerator/AppDaoGenerator.java index e73edc1..51bf2d2 100644 --- a/DaoGenerator/src/main/java/orz/sorz/lab/smallcloudemoji/daogenerator/AppDaoGenerator.java +++ b/DaoGenerator/src/main/java/orz/sorz/lab/smallcloudemoji/daogenerator/AppDaoGenerator.java @@ -9,7 +9,7 @@ public class AppDaoGenerator { public static void main(String[] args) throws Exception { - Schema schema = new Schema(1, "org.sorz.lab.smallcloudemoji.db"); + Schema schema = new Schema(2, "org.sorz.lab.smallcloudemoji.db"); addEntities(schema); addSources(schema); diff --git a/app/app.iml b/app/app.iml index a4cf0e0..8a6a97f 100755 --- a/app/app.iml +++ b/app/app.iml @@ -8,12 +8,10 @@ - - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/app/src/main/java/org/sorz/lab/smallcloudemoji/db/DatabaseHelper.java b/app/src/main/java/org/sorz/lab/smallcloudemoji/db/DatabaseHelper.java index 2ac09d1..bb68540 100644 --- a/app/src/main/java/org/sorz/lab/smallcloudemoji/db/DatabaseHelper.java +++ b/app/src/main/java/org/sorz/lab/smallcloudemoji/db/DatabaseHelper.java @@ -28,7 +28,7 @@ public static synchronized DatabaseHelper getInstance(Context context, Boolean i } private DatabaseHelper(Context context) { - DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(context, "repo.db", null); + DaoMaster.OpenHelper helper = new ReleaseOpenHelper(context, "repo.db", null); SQLiteDatabase db = helper.getWritableDatabase(); daoMaster = new DaoMaster(db); daoSession = daoMaster.newSession(); diff --git a/app/src/main/java/org/sorz/lab/smallcloudemoji/db/ReleaseOpenHelper.java b/app/src/main/java/org/sorz/lab/smallcloudemoji/db/ReleaseOpenHelper.java new file mode 100644 index 0000000..124d215 --- /dev/null +++ b/app/src/main/java/org/sorz/lab/smallcloudemoji/db/ReleaseOpenHelper.java @@ -0,0 +1,17 @@ +package org.sorz.lab.smallcloudemoji.db; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; + +public class ReleaseOpenHelper extends DaoMaster.OpenHelper { + public ReleaseOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + if (oldVersion == 1 && newVersion == 2) { + SourceDao.createTable(db, false); + } + } +}