Java Code Examples for androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory

The following examples show how to use androidx.sqlite.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: cwac-saferoom   Source File: RekeyTest.java    License: 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 Project: cwac-saferoom   Source File: RekeyTest.java    License: 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 Project: sqlitemagic   Source File: TestApp.java    License: 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 Project: sqlitemagic   Source File: DbDefaultConnectionTest.java    License: 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 Project: sqlitemagic   Source File: DbConnectionTest.java    License: 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 Project: puree-android   Source File: PureeSQLiteStorage.java    License: 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 Project: dbsync   Source File: DbSyncApplication.java    License: 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
public DatabaseMigrationTest() {
    helper = new MigrationTestHelper(
            InstrumentationRegistry.getInstrumentation(),
            AppDatabase.class.getCanonicalName(),
            new FrameworkSQLiteOpenHelperFactory());
}