android.arch.persistence.db.SupportSQLiteOpenHelper Java Examples

The following examples show how to use android.arch.persistence.db.SupportSQLiteOpenHelper. 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: BriteDatabase.java    From sqlbrite with Apache License 2.0 5 votes vote down vote up
BriteDatabase(SupportSQLiteOpenHelper helper, Logger logger, Scheduler scheduler,
    ObservableTransformer<Query, Query> queryTransformer) {
  this.helper = helper;
  this.logger = logger;
  this.scheduler = scheduler;
  this.queryTransformer = queryTransformer;
}
 
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;
}
 
Example #5
Source File: LauncherActivity.java    From SqliteManager with Apache License 2.0 4 votes vote down vote up
RoomSqliteDataRetriever(SupportSQLiteOpenHelper sqliteHelper) {
    mSqliteHelper = sqliteHelper;
}
 
Example #6
Source File: SqlBrite.java    From sqlbrite with Apache License 2.0 2 votes vote down vote up
/**
 * Wrap a {@link SupportSQLiteOpenHelper} for observable queries.
 * <p>
 * While not strictly required, instances of this class assume that they will be the only ones
 * interacting with the underlying {@link SupportSQLiteOpenHelper} and it is required for
 * automatic notifications of table changes to work. See {@linkplain BriteDatabase#createQuery the
 * <code>query</code> method} for more information on that behavior.
 *
 * @param scheduler The {@link Scheduler} on which items from {@link BriteDatabase#createQuery}
 * will be emitted.
 */
@CheckResult @NonNull public BriteDatabase wrapDatabaseHelper(
    @NonNull SupportSQLiteOpenHelper helper,
    @NonNull Scheduler scheduler) {
  return new BriteDatabase(helper, logger, scheduler, queryTransformer);
}