Java Code Examples for android.arch.persistence.db.framework.FrameworkSQLiteOpenHelperFactory

The following examples show how to use android.arch.persistence.db.framework.FrameworkSQLiteOpenHelperFactory. 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: sqlbrite   Source File: BriteDatabaseTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before public void setUp() throws IOException {
  Configuration configuration = Configuration.builder(InstrumentationRegistry.getContext())
      .callback(testDb)
      .name(dbFolder.newFile().getPath())
      .build();

  Factory factory = new FrameworkSQLiteOpenHelperFactory();
  SupportSQLiteOpenHelper helper = factory.create(configuration);
  real = helper.getWritableDatabase();

  SqlBrite.Logger logger = new SqlBrite.Logger() {
    @Override public void log(String message) {
      logs.add(message);
    }
  };
  ObservableTransformer<Query, Query> queryTransformer =
      new ObservableTransformer<Query, Query>() {
        @Override public ObservableSource<Query> apply(Observable<Query> upstream) {
          return upstream.takeUntil(killSwitch);
        }
      };
  db = new BriteDatabase(helper, logger, scheduler, queryTransformer);
}
 
Example 2
Source Project: sqlitemagic   Source File: SampleApp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();
  SqliteMagic.builder(this)
      .sqliteFactory(new FrameworkSQLiteOpenHelperFactory())
      .openDefaultConnection();
}
 
Example 3
Source Project: sqlbrite   Source File: QueryTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before public void setUp() {
  Configuration configuration = Configuration.builder(InstrumentationRegistry.getContext())
      .callback(new TestDb())
      .build();

  Factory factory = new FrameworkSQLiteOpenHelperFactory();
  SupportSQLiteOpenHelper helper = factory.create(configuration);

  SqlBrite sqlBrite = new SqlBrite.Builder().build();
  db = sqlBrite.wrapDatabaseHelper(helper, Schedulers.trampoline());
}
 
Example 4
Source Project: sqlbrite   Source File: DbModule.java    License: Apache License 2.0 5 votes vote down vote up
@Provides @Singleton BriteDatabase provideDatabase(SqlBrite sqlBrite, Application application) {
  Configuration configuration = Configuration.builder(application)
      .name("todo.db")
      .callback(new DbCallback())
      .build();
  Factory factory = new FrameworkSQLiteOpenHelperFactory();
  SupportSQLiteOpenHelper helper = factory.create(configuration);
  BriteDatabase db = sqlBrite.wrapDatabaseHelper(helper, Schedulers.io());
  db.setLoggingEnabled(true);
  return db;
}