androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory Java Examples

The following examples show how to use androidx.sqlite.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: RekeyTest.java    From cwac-saferoom with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void rekeyEditableFramework() throws IOException {
  FrameworkSQLiteOpenHelperFactory factory=new FrameworkSQLiteOpenHelperFactory();
  SupportSQLiteOpenHelper.Configuration cfg=
      SupportSQLiteOpenHelper.Configuration.builder(InstrumentationRegistry.getTargetContext())
          .callback(new Callback(1))
          .name(DB_NAME)
          .build();
  SupportSQLiteOpenHelper helper=factory.create(cfg);
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  SafeHelperFactory.rekey(db, new SpannableStringBuilder(PASSPHRASE));
  db.close();
}
 
Example #2
Source File: RekeyTest.java    From cwac-saferoom with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void rekeyCharArrayFramework() throws IOException {
  FrameworkSQLiteOpenHelperFactory factory=new FrameworkSQLiteOpenHelperFactory();
  SupportSQLiteOpenHelper.Configuration cfg=
      SupportSQLiteOpenHelper.Configuration.builder(InstrumentationRegistry.getTargetContext())
          .callback(new Callback(1))
          .name(DB_NAME)
          .build();
  SupportSQLiteOpenHelper helper=factory.create(cfg);
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  SafeHelperFactory.rekey(db, PASSPHRASE.toCharArray());
}
 
Example #3
Source File: TestApp.java    From sqlitemagic with Apache License 2.0 5 votes vote down vote up
public static void initDb(@NonNull Application app) {
  SqliteMagic.setLoggingEnabled(true);
  SqliteMagic.builder(app)
      .sqliteFactory(new FrameworkSQLiteOpenHelperFactory())
      .scheduleRxQueriesOn(Schedulers.trampoline())
      .openDefaultConnection();
}
 
Example #4
Source File: DbDefaultConnectionTest.java    From sqlitemagic with Apache License 2.0 5 votes vote down vote up
private void initDbWithNewConnection() {
  SqliteMagic.builder(TestApp.INSTANCE)
      .name("new.db")
      .sqliteFactory(new FrameworkSQLiteOpenHelperFactory())
      .scheduleRxQueriesOn(Schedulers.trampoline())
      .openDefaultConnection();
}
 
Example #5
Source File: DbConnectionTest.java    From sqlitemagic with Apache License 2.0 5 votes vote down vote up
@NonNull
private DbConnection openNewConnection() {
  return SqliteMagic
      .builder(TestApp.INSTANCE)
      .name("newConnection.db")
      .sqliteFactory(new FrameworkSQLiteOpenHelperFactory())
      .scheduleRxQueriesOn(Schedulers.trampoline())
      .openNewConnection();
}
 
Example #6
Source File: PureeSQLiteStorage.java    From puree-android with MIT License 5 votes vote down vote up
public PureeSQLiteStorage(Context context) {
    super(DATABASE_VERSION);
    openHelper = new FrameworkSQLiteOpenHelperFactory()
            .create(
                    SupportSQLiteOpenHelper.Configuration
                            .builder(context)
                            .name(databaseName(context))
                            .callback(this)
                            .build()
            );
}
 
Example #7
Source File: DbSyncApplication.java    From dbsync with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    SupportSQLiteOpenHelper.Configuration  configuration;
    super.onCreate();

    StaticLoggerBinder.init(this);
    log = LoggerFactory.getLogger(DbSyncApplication.class);

    log.info("onCreate");


    configuration = SupportSQLiteOpenHelper.Configuration.builder(this)
            .name("db1")
            .callback(new Db1Callback())
            .build();
    db1OpenHelper = new FrameworkSQLiteOpenHelperFactory()
            .create(configuration);
    db1OpenHelper.getReadableDatabase();

    configuration = SupportSQLiteOpenHelper.Configuration.builder(this)
            .name("db2")
            .callback(new Db2Callback())
            .build();
    db2OpenHelper = new FrameworkSQLiteOpenHelperFactory()
            .create(configuration);
    db2OpenHelper.getReadableDatabase();

    configuration = SupportSQLiteOpenHelper.Configuration.builder(this)
            .name("db3")
            .callback(new Db3Callback())
            .build();
    db3OpenHelper = new FrameworkSQLiteOpenHelperFactory()
            .create(configuration);
    db3OpenHelper.getReadableDatabase();

    configuration = SupportSQLiteOpenHelper.Configuration.builder(this)
            .name("db4")
            .callback(new Db4Callback())
            .build();
    db4OpenHelper = new FrameworkSQLiteOpenHelperFactory()
            .create(configuration);
    db4OpenHelper.getReadableDatabase();


    configuration = SupportSQLiteOpenHelper.Configuration.builder(this)
            .name("db5")
            .callback(new Db5Callback())
            .build();
    db5OpenHelper = new FrameworkSQLiteOpenHelperFactory()
            .create(configuration);
    db5OpenHelper.getReadableDatabase();
}
 
Example #8
Source File: DatabaseMigrationTest.java    From openScale with GNU General Public License v3.0 4 votes vote down vote up
public DatabaseMigrationTest() {
    helper = new MigrationTestHelper(
            InstrumentationRegistry.getInstrumentation(),
            AppDatabase.class.getCanonicalName(),
            new FrameworkSQLiteOpenHelperFactory());
}