Java Code Examples for io.requery.android.sqlite.DatabaseSource

The following examples show how to use io.requery.android.sqlite.DatabaseSource. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: requery   Source File: SqliteFunctionalTest.java    License: Apache License 2.0 6 votes vote down vote up
public SqliteFunctionalTest(Type type) {
    EntityModel model = Models.DEFAULT;
    Context context = InstrumentationRegistry.getContext();
    dbName = type.toString().toLowerCase() + ".db";
    switch (type) {
        default:
        case ANDROID:
            dataSource = new DatabaseSource(context, model, dbName, 1);
            break;
        case SUPPORT:
            dataSource = new SqlitexDatabaseSource(context, model, dbName, 1);
            break;
        case SQLCIPHER:
            dataSource = new SqlCipherDatabaseSource(context, model, dbName, "test123", 1);
            break;
    }
}
 
Example 2
Source Project: AndroidStarterAlt   Source File: MockModuleDatabase.java    License: Apache License 2.0 5 votes vote down vote up
@Provides
@Singleton
@Override
public SingleEntityStore<Persistable> provideDataStore(@NonNull final Context poContext) {
    final DatabaseSource loSource = new DatabaseSource(poContext, Models.DEFAULT, "mock_android_starter_alt.sqlite", 1);
    final Configuration loConfiguration = loSource.getConfiguration();
    final SingleEntityStore<Persistable> loDataStore = RxSupport.toReactiveStore(new EntityDataStore<>(loConfiguration));
    return loDataStore;
}
 
Example 3
Source Project: pretixdroid   Source File: PretixDroid.java    License: GNU General Public License v3.0 5 votes vote down vote up
public BlockingEntityStore<Persistable> getData() {
    if (dataStore == null) {
        // override onUpgrade to handle migrating to a new version
        DatabaseSource source = new DatabaseSource(this, Models.DEFAULT, 6);
        Configuration configuration = source.getConfiguration();
        dataStore = new EntityDataStore<Persistable>(configuration);
    }
    return dataStore;
}
 
Example 4
Source Project: requery   Source File: PeopleApplication.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example 5
private void setupDatabase() {
    DatabaseSource source = new DatabaseSource(getTargetContext(), Models.DEFAULT,
            DATABASE_VERSION);
    Configuration configuration = new ConfigurationBuilder(source,
            Models.DEFAULT).setEntityCache(new EmptyEntityCache()).build();
    database = new EntityDataStore<>(configuration).toBlocking();
}