io.requery.android.sqlite.DatabaseSource Java Examples

The following examples show how to use io.requery.android.sqlite.DatabaseSource. 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 File: SqliteFunctionalTest.java    From requery with 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 File: MockModuleDatabase.java    From AndroidStarterAlt with 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 File: PretixDroid.java    From pretixdroid with 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 File: PeopleApplication.java    From requery with 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
Source File: PerfTestRequery.java    From android-database-performance with Apache License 2.0 5 votes vote down vote up
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();
}