Skip to content

@BindDataSourceUpdateTask

xcesco edited this page May 2, 2018 · 1 revision

Database schema migrations are managed by migration tasks that are defined by SQLiteUpdateTask derived classes. You can define an update tasks set:

  • By code, typically in Application#onCreate method.
  • By annotation, in @BindDataSourceOptions annotation used in a data source definition.
@BindDataSourceOptions(updateTasks = {
  @BindDataSourceUpdateTask(version = 2, task = PersonUpdateTask.class) 
})
@BindDataSource(daoSet = { DaoPerson.class }, fileName = "app.db")
public interface AppDataSource {

}

@BindDataSourceUpdateTask(version = 2, task = PersonUpdateTask.class) will use the class PersonUpdateTask to migrate from version 1 to version 2. Migration tasks support database migration from version n to version n+1. No gap versions are allowed. For this reason, you need only to specify target version, since star version is always defined as target version - 1.

public class PersonUpdateTask implements SQLiteUpdateTask {
  @Override
  public void execute(SQLiteDatabase database, int previousVersion, int currentVersion) {
    ...		
  }
}

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally