use of com.abubusoft.kripton.android.sqlite.DatabaseLifecycleHandler in project kripton by xcesco.
the class TestKripton234Runtime method testRunSqlite2.
@Test
public void testRunSqlite2() throws IOException, InstantiationException, IllegalAccessException {
DataSourceOptions.Builder optionsBuilder = DataSourceOptions.builder();
optionsBuilder.inMemory(false);
optionsBuilder.databaseLifecycleHandler(new DatabaseLifecycleHandler() {
@Override
public void onUpdate(SQLiteDatabase database, int oldVersion, int newVersion, boolean upgrade) {
log("databaseLifecycleHandler - onUpdate");
}
@Override
public void onCreate(SQLiteDatabase database) {
log("databaseLifecycleHandler - onCreate " + database.getVersion());
}
@Override
public void onConfigure(SQLiteDatabase database) {
log("databaseLifecycleHandler - onConfigure");
}
});
optionsBuilder.addUpdateTask(1, new SQLiteUpdateTask() {
@Override
public void execute(SQLiteDatabase database, int previousVersion, int currentVersion) {
log("aaaaaaaaa");
}
});
BindAppWithConfigDataSource ds = BindAppWithConfigDataSource.build(optionsBuilder.build());
}
use of com.abubusoft.kripton.android.sqlite.DatabaseLifecycleHandler in project kripton by xcesco.
the class TestSchemaRuntime method testRun.
@Test
public void testRun() {
BindSchoolDataSource.build(DataSourceOptions.builder().databaseLifecycleHandler(new DatabaseLifecycleHandler() {
@Override
public void onUpdate(SQLiteDatabase db, int oldVersion, int newVersion, boolean upgrade) {
// TODO Auto-generated method stub
}
@Override
public void onCreate(SQLiteDatabase database) {
// TODO Auto-generated method stub
}
@Override
public void onConfigure(SQLiteDatabase database) {
// TODO Auto-generated method stub
}
}).build());
try (BindSchoolDataSource dataSource = BindSchoolDataSource.open();
DaoProfessorImpl dao = dataSource.getDaoProfessor()) {
// dataSource.execute(transaction);
for (int i = 0; i < 10; i++) {
Professor professor = new Professor();
professor.name = String.format("professor%03d", i);
professor.surname = "surname" + i;
professor.birthDate = new Date();
dao.insert(professor);
}
}
try (BindSchoolDataSource dataSource = BindSchoolDataSource.open();
DaoStudentImpl dao = dataSource.getDaoStudent()) {
// dataSource.execute(transaction);
for (int i = 0; i < 100; i++) {
Student student = new Student();
student.name = String.format("professor%03d", i);
student.location = String.format("location%03d", i);
dao.insert(student);
}
}
}
Aggregations