|
@@ -8,9 +8,9 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|
* 创建数据库保存失败的进出记录
|
|
* 创建数据库保存失败的进出记录
|
|
*/
|
|
*/
|
|
public class RecordSaveHelper extends SQLiteOpenHelper {
|
|
public class RecordSaveHelper extends SQLiteOpenHelper {
|
|
- private static Integer version = 1;
|
|
|
|
|
|
+ private static Integer version = 2;
|
|
private static String name = "recordSave.db";
|
|
private static String name = "recordSave.db";
|
|
-
|
|
|
|
|
|
+ private final String TABLENAME = "recordSave";
|
|
public RecordSaveHelper(Context context) {
|
|
public RecordSaveHelper(Context context) {
|
|
super(context, name, null, version);
|
|
super(context, name, null, version);
|
|
}
|
|
}
|
|
@@ -22,8 +22,11 @@ public class RecordSaveHelper extends SQLiteOpenHelper {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
|
|
|
|
-
|
|
|
|
|
|
+ public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
|
|
|
|
+ if (newVersion > oldVersion) {
|
|
|
|
+ sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLENAME);
|
|
|
|
+ onCreate(sqLiteDatabase);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|