Search in sources :

Example 1 with DatabaseSource

use of io.requery.android.sqlite.DatabaseSource in project requery by requery.

the class PeopleApplication method getData.

/**
     * @return {@link EntityDataStore} single instance for the application.
     * <p/>
     * Note if you're using Dagger you can make this part of your application level module returning
     * {@code @Provides @Singleton}.
     */
ReactiveEntityStore<Persistable> getData() {
    if (dataStore == null) {
        // override onUpgrade to handle migrating to a new version
        DatabaseSource source = new DatabaseSource(this, Models.DEFAULT, 1);
        if (BuildConfig.DEBUG) {
            // use this in development mode to drop and recreate the tables on every upgrade
            source.setTableCreationMode(TableCreationMode.DROP_CREATE);
        }
        Configuration configuration = source.getConfiguration();
        dataStore = ReactiveSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
    }
    return dataStore;
}
Also used : DatabaseSource(io.requery.android.sqlite.DatabaseSource) Configuration(io.requery.sql.Configuration) EntityDataStore(io.requery.sql.EntityDataStore)

Aggregations

DatabaseSource (io.requery.android.sqlite.DatabaseSource)1 Configuration (io.requery.sql.Configuration)1 EntityDataStore (io.requery.sql.EntityDataStore)1