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

The following examples show how to use android.arch.persistence.db.framework.FrameworkSQLiteOpenHelperFactory. 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: BriteDatabaseTest.java    From sqlbrite with 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 File: SampleApp.java    From sqlitemagic with 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 File: QueryTest.java    From sqlbrite with 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 File: DbModule.java    From sqlbrite with 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;
}