| 1 |
gabriel |
1 |
package com.cesams.twogetskills.dao;
|
|
|
2 |
|
|
|
3 |
import android.content.Context;
|
|
|
4 |
|
|
|
5 |
import androidx.room.Room;
|
| 19 |
gabriel |
6 |
import androidx.room.migration.Migration;
|
|
|
7 |
import androidx.sqlite.db.SupportSQLiteDatabase;
|
| 1 |
gabriel |
8 |
|
|
|
9 |
import com.cesams.twogetskills.Constants;
|
| 19 |
gabriel |
10 |
import com.cesams.twogetskills.entity.NotificationCenter;
|
| 1 |
gabriel |
11 |
|
|
|
12 |
public class DatabaseHelper {
|
|
|
13 |
|
|
|
14 |
//Control de cambio de capsula
|
| 3 |
gabriel |
15 |
//public static String CambioSlide = "NO"; // SI o NO
|
|
|
16 |
//public static String ResumenVisores ="NO";
|
|
|
17 |
//public static String imagenviewerontrol= "NO";
|
| 1 |
gabriel |
18 |
|
|
|
19 |
private static DatabaseHelper _INSTANCE = null;
|
|
|
20 |
private AppDatabase appDatabase;
|
|
|
21 |
|
|
|
22 |
// other instance variables can be here
|
|
|
23 |
|
|
|
24 |
private DatabaseHelper(Context context) {
|
|
|
25 |
appDatabase = Room.databaseBuilder(
|
|
|
26 |
context.getApplicationContext(),
|
|
|
27 |
AppDatabase.class, Constants.DATABASE_FILENAME
|
| 19 |
gabriel |
28 |
).allowMainThreadQueries().addMigrations(MIGRATION_1_2).fallbackToDestructiveMigration()
|
|
|
29 |
.build();
|
| 1 |
gabriel |
30 |
};
|
|
|
31 |
|
| 19 |
gabriel |
32 |
static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
|
|
33 |
@Override
|
|
|
34 |
public void migrate(SupportSQLiteDatabase database) {
|
|
|
35 |
database.execSQL("CREATE TABLE `tb_notification` (`id` INTEGER NOT NULL, "
|
|
|
36 |
+ "`title` TEXT,`date` TEXT,`description` TEXT, PRIMARY KEY(`id`))");
|
| 21 |
gabriel |
37 |
|
|
|
38 |
database.execSQL("ALTER TABLE `tb_capsules`"
|
|
|
39 |
+ "ADD COLUMN added_on TEXT");
|
|
|
40 |
|
|
|
41 |
database.execSQL("ALTER TABLE `tb_capsules`"
|
|
|
42 |
+ "ADD COLUMN updated_on TEXT");
|
|
|
43 |
|
|
|
44 |
database.execSQL("ALTER TABLE `tb_topics`"
|
|
|
45 |
+ "ADD COLUMN updated_on TEXT");
|
|
|
46 |
|
|
|
47 |
database.execSQL("ALTER TABLE `tb_topics`"
|
|
|
48 |
+ "ADD COLUMN updated_on TEXT");
|
|
|
49 |
|
|
|
50 |
|
| 19 |
gabriel |
51 |
}
|
|
|
52 |
};
|
|
|
53 |
|
| 1 |
gabriel |
54 |
public static DatabaseHelper getInstance(Context context) {
|
|
|
55 |
if (_INSTANCE == null) {
|
|
|
56 |
_INSTANCE = new DatabaseHelper(context);
|
|
|
57 |
}
|
|
|
58 |
return(_INSTANCE);
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
public AppDatabase getAppDatabase() {
|
|
|
62 |
return appDatabase;
|
|
|
63 |
}
|
|
|
64 |
}
|