Java Code Examples for androidx.sqlite.db.SupportSQLiteOpenHelper

The following examples show how to use androidx.sqlite.db.SupportSQLiteOpenHelper. 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: PassphraseClearTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void charArrayCleared() throws IOException {
  char[] charArray = PASSPHRASE.toCharArray();
  SafeHelperFactory factory=new SafeHelperFactory(charArray);
  SupportSQLiteOpenHelper helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  helper.close();

  char[] expected = new char[charArray.length];

  for (int i=0;i<expected.length;i++) {
    expected[i]=(char)0;
  }

  assertArrayEquals(expected, charArray);
}
 
Example 2
Source Project: cwac-saferoom   Source File: PassphraseClearTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void byteArrayCleared() throws IOException {
  char[] charArray = PASSPHRASE.toCharArray();
  byte[] byteArray = SQLiteDatabase.getBytes(charArray);
  SafeHelperFactory factory=new SafeHelperFactory(byteArray);
  SupportSQLiteOpenHelper helper=
      factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
          new Callback(1));
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  helper.close();

  byte[] expected = new byte[byteArray.length];

  for (int i=0;i<expected.length;i++) {
    expected[i]=(byte)0;
  }

  assertArrayEquals(expected, byteArray);
}
 
Example 3
Source Project: cwac-saferoom   Source File: CloseThenOpenTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void defaultReopenClosedHelper() throws IOException {
  SafeHelperFactory factory=
    SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
  SupportSQLiteOpenHelper helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  helper.close();

  helper=
      factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
          new Callback(1));
  SupportSQLiteDatabase db2=helper.getWritableDatabase();

  db2.close();
}
 
Example 4
Source Project: cwac-saferoom   Source File: CloseThenOpenTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void explicitClearReopenClosedHelper() throws IOException {
  SafeHelperFactory factory=
      SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE),
          SafeHelperFactory.Options.builder().setClearPassphrase(true).build());
  SupportSQLiteOpenHelper helper=
      factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
          new Callback(1));
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  helper.close();

  helper=
      factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
          new Callback(1));
  SupportSQLiteDatabase db2=helper.getWritableDatabase();

  db2.close();
}
 
Example 5
Source Project: cwac-saferoom   Source File: CloseThenOpenTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void clearOutOutReopenClosedHelper() throws IOException {
  SafeHelperFactory factory=
      SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE),
          SafeHelperFactory.Options.builder().setClearPassphrase(false).build());
  SupportSQLiteOpenHelper helper=
      factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
          new Callback(1));
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  helper.close();

  helper=
      factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
          new Callback(1));
  SupportSQLiteDatabase db2=helper.getWritableDatabase();

  db2.close();
}
 
Example 6
Source Project: cwac-saferoom   Source File: PostHookSqlTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void migrate() throws IOException {
  assertTrue(getDbFile().exists());

  SafeHelperFactory factory=
    SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE),
      SafeHelperFactory.POST_KEY_SQL_MIGRATE);
  SupportSQLiteOpenHelper helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  SupportSQLiteDatabase db=helper.getReadableDatabase();

  assertOriginalContent(db);
  db.close();

  // with migrate, the change should be permanent

  factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
  helper=factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  db=helper.getReadableDatabase();

  assertOriginalContent(db);
  db.close();
}
 
Example 7
Source Project: cwac-saferoom   Source File: SafeFactoryProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void tearDownDatabase(Context ctxt,
                             SupportSQLiteOpenHelper.Factory factory,
                             SupportSQLiteOpenHelper helper) {
  String name=helper.getDatabaseName();

  if (name!=null) {
    File db=ctxt.getDatabasePath(name);

    if (db.exists()) {
      db.delete();
    }

    File journal=new File(db.getParentFile(), name+"-journal");

    if (journal.exists()) {
      journal.delete();
    }
  }
}
 
Example 8
Source Project: cwac-saferoom   Source File: RekeyTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void rekeyEditable() throws IOException {
  SafeHelperFactory factory=
    SafeHelperFactory.fromUser(new SpannableStringBuilder("sekrit"));
  SupportSQLiteOpenHelper helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  assertOriginalContent(db);
  SafeHelperFactory.rekey(db, new SpannableStringBuilder(PASSPHRASE));
  assertOriginalContent(db);
  db.execSQL("UPDATE foo SET bar=?, goo=?", new Object[] {3, "four"});
  assertUpdatedContent(db);
  db.close();

  factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
  helper=factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
    new Callback(1));
  db=helper.getWritableDatabase();
  assertUpdatedContent(db);
}
 
Example 9
Source Project: cwac-saferoom   Source File: RekeyTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void rekeyCharArray() throws IOException {
  SafeHelperFactory factory=
          SafeHelperFactory.fromUser(new SpannableStringBuilder("sekrit"));
  SupportSQLiteOpenHelper helper=
          factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
                  new Callback(1));
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  assertOriginalContent(db);
  SafeHelperFactory.rekey(db, PASSPHRASE.toCharArray());
  assertOriginalContent(db);
  db.execSQL("UPDATE foo SET bar=?, goo=?", new Object[] {3, "four"});
  assertUpdatedContent(db);
  db.close();

  factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
  helper=factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
          new Callback(1));
  db=helper.getWritableDatabase();
  assertUpdatedContent(db);
}
 
Example 10
Source Project: mimi-reader   Source File: ActiveAndroidSqlBriteBridge.java    License: Apache License 2.0 6 votes vote down vote up
private static SupportSQLiteOpenHelper getSQLiteOpenHelper() {
    try {
        Field dhField = com.activeandroid.Cache.class.getDeclaredField("sDatabaseHelper");
        dhField.setAccessible(true);
        SupportSQLiteOpenHelper helper = (SupportSQLiteOpenHelper) dhField.get(null);
        if (helper == null) {
            throw new IllegalStateException("Could not get SQLiteOpenHelper from Active Android");
        } else {
            return helper;
        }
    } catch (IllegalAccessException | NoSuchFieldException e) {
        e.printStackTrace();
    }

    return null;
}
 
Example 11
SQLiteCopyOpenHelperFactory(
        @Nullable String copyFromAssetPath,
        @Nullable File copyFromFile,
        @NonNull SupportSQLiteOpenHelper.Factory factory) {
    mCopyFromAssetPath = copyFromAssetPath;
    mCopyFromFile = copyFromFile;
    mDelegate = factory;
}
 
Example 12
@Override
public SupportSQLiteOpenHelper create(SupportSQLiteOpenHelper.Configuration configuration) {
    return new SQLiteCopyOpenHelper(
            configuration.context,
            mCopyFromAssetPath,
            mCopyFromFile,
            configuration.callback.version,
            mDelegate.create(configuration));
}
 
Example 13
/**
 * Creates a database configuration with the given values.
 *
 * @param context The application context.
 * @param name Name of the database, can be null if it is in memory.
 * @param sqliteOpenHelperFactory The open helper factory to use.
 * @param migrationContainer The migration container for migrations.
 * @param callbacks The list of callbacks for database events.
 * @param allowMainThreadQueries Whether to allow main thread reads/writes or not.
 * @param journalMode The journal mode. This has to be either TRUNCATE or WRITE_AHEAD_LOGGING.
 * @param queryExecutor The Executor used to execute asynchronous queries.
 * @param transactionExecutor The Executor used to execute asynchronous transactions.
 * @param multiInstanceInvalidation True if Room should perform multi-instance invalidation.
 * @param requireMigration True if Room should require a valid migration if version changes,
 * @param allowDestructiveMigrationOnDowngrade True if Room should recreate tables if no
 *                                             migration is supplied during a downgrade.
 * @param migrationNotRequiredFrom The collection of schema versions from which migrations
 *                                 aren't required.
 * @param copyFromAssetPath The assets path to the pre-packaged database.
 * @param copyFromFile The pre-packaged database file.
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
public DatabaseConfiguration(@NonNull Context context, @Nullable String name,
        @NonNull SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory,
        @NonNull RoomDatabase.MigrationContainer migrationContainer,
        @Nullable List<RoomDatabase.Callback> callbacks,
        boolean allowMainThreadQueries,
        RoomDatabase.JournalMode journalMode,
        @NonNull Executor queryExecutor,
        @NonNull Executor transactionExecutor,
        boolean multiInstanceInvalidation,
        boolean requireMigration,
        boolean allowDestructiveMigrationOnDowngrade,
        @Nullable Set<Integer> migrationNotRequiredFrom,
        @Nullable String copyFromAssetPath,
        @Nullable File copyFromFile) {
    this.sqliteOpenHelperFactory = sqliteOpenHelperFactory;
    this.context = context;
    this.name = name;
    this.migrationContainer = migrationContainer;
    this.callbacks = callbacks;
    this.allowMainThreadQueries = allowMainThreadQueries;
    this.journalMode = journalMode;
    this.queryExecutor = queryExecutor;
    this.transactionExecutor = transactionExecutor;
    this.multiInstanceInvalidation = multiInstanceInvalidation;
    this.requireMigration = requireMigration;
    this.allowDestructiveMigrationOnDowngrade = allowDestructiveMigrationOnDowngrade;
    this.mMigrationNotRequiredFrom = migrationNotRequiredFrom;
    this.copyFromAssetPath = copyFromAssetPath;
    this.copyFromFile = copyFromFile;
}
 
Example 14
SQLiteCopyOpenHelper(
        @NonNull Context context,
        @Nullable String copyFromAssetPath,
        @Nullable File copyFromFile,
        int databaseVersion,
        @NonNull SupportSQLiteOpenHelper supportSQLiteOpenHelper) {
    mContext = context;
    mCopyFromAssetPath = copyFromAssetPath;
    mCopyFromFile = copyFromFile;
    mDatabaseVersion = databaseVersion;
    mDelegate = supportSQLiteOpenHelper;
}
 
Example 15
Source Project: cwac-saferoom   Source File: SafeHelperFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public SupportSQLiteOpenHelper create(
  SupportSQLiteOpenHelper.Configuration configuration) {
  return(create(configuration.context, configuration.name,
    configuration.callback));
}
 
Example 16
Source Project: cwac-saferoom   Source File: PreHookSqlTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testPreKeySql() throws IOException {
  SafeHelperFactory.Options options = SafeHelperFactory.Options.builder().setPreKeySql(PREKEY_SQL).build();
  SafeHelperFactory factory=
    SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE), options);
  SupportSQLiteOpenHelper helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  assertEquals(1, db.getVersion());

  db.close();
}
 
Example 17
Source Project: cwac-saferoom   Source File: PostHookSqlTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected = net.sqlcipher.database.SQLiteException.class)
public void defaultBehavior() throws IOException {
  assertTrue(getDbFile().exists());

  SafeHelperFactory factory=
    SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
  SupportSQLiteOpenHelper helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  SupportSQLiteDatabase db=helper.getReadableDatabase();

  db.close();
}
 
Example 18
Source Project: cwac-saferoom   Source File: PostHookSqlTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void v3() throws IOException {
  assertTrue(getDbFile().exists());

  SafeHelperFactory factory=
    SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE),
      SafeHelperFactory.POST_KEY_SQL_V3);
  SupportSQLiteOpenHelper helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  SupportSQLiteDatabase db=helper.getReadableDatabase();

  assertOriginalContent(db);
  db.close();

  // with v3, the change should be temporary

  factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
  helper=factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
    new Callback(1));

  boolean didWeGoBoom = false;

  try {
    db = helper.getReadableDatabase();
  }
  catch (net.sqlcipher.database.SQLiteException ex) {
    didWeGoBoom = true;
  }

  assertTrue(didWeGoBoom);
}
 
Example 19
Source Project: cwac-saferoom   Source File: EncryptTest.java    License: Apache License 2.0 5 votes vote down vote up
private void enkey(Callable<?> encrypter) throws Exception {
  final Context ctxt=InstrumentationRegistry.getTargetContext();

  assertEquals(SQLCipherUtils.State.DOES_NOT_EXIST, SQLCipherUtils.getDatabaseState(ctxt, DB_NAME));

  SQLiteDatabase plainDb=
    SQLiteDatabase.openOrCreateDatabase(ctxt.getDatabasePath(DB_NAME).getAbsolutePath(),
      null);

  plainDb.execSQL("CREATE TABLE foo (bar, goo);");
  plainDb.execSQL("INSERT INTO foo (bar, goo) VALUES (?, ?)",
    new Object[] {1, "two"});

  assertOriginalContent(plainDb);
  plainDb.close();

  assertEquals(SQLCipherUtils.State.UNENCRYPTED, SQLCipherUtils.getDatabaseState(ctxt, DB_NAME));

  encrypter.call();

  assertEquals(SQLCipherUtils.State.ENCRYPTED, SQLCipherUtils.getDatabaseState(ctxt, DB_NAME));

  SafeHelperFactory factory=
    SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
  SupportSQLiteOpenHelper helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  SupportSQLiteDatabase db=helper.getReadableDatabase();

  assertOriginalContent(db);
  db.close();
}
 
Example 20
Source Project: cwac-saferoom   Source File: WALTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void wal() throws IOException {
  SafeHelperFactory factory=
    SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
  SupportSQLiteOpenHelper helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  assertFalse(db.isWriteAheadLoggingEnabled());

  assertTrue(db.enableWriteAheadLogging());
  assertTrue(db.isWriteAheadLoggingEnabled());

  db.close();

  factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
  helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  db=helper.getWritableDatabase();

  assertTrue(db.isWriteAheadLoggingEnabled());
  db.disableWriteAheadLogging();
  assertFalse(db.isWriteAheadLoggingEnabled());

  db.close();
}
 
Example 21
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 22
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 23
Source Project: cwac-saferoom   Source File: DecryptTest.java    License: Apache License 2.0 5 votes vote down vote up
private void dekey(Callable<?> decrypter) throws Exception {
  final Context ctxt=InstrumentationRegistry.getTargetContext();

  assertEquals(SQLCipherUtils.State.DOES_NOT_EXIST, SQLCipherUtils.getDatabaseState(ctxt, DB_NAME));

  SafeHelperFactory factory=
    SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
  SupportSQLiteOpenHelper helper=
    factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
      new Callback(1));
  SupportSQLiteDatabase db=helper.getWritableDatabase();

  assertOriginalContent(db);
  db.close();

  assertEquals(SQLCipherUtils.State.ENCRYPTED, SQLCipherUtils.getDatabaseState(ctxt, DB_NAME));

  decrypter.call();

  SQLiteDatabase plainDb=
    SQLiteDatabase.openDatabase(ctxt.getDatabasePath(DB_NAME).getAbsolutePath(),
      null, SQLiteDatabase.OPEN_READWRITE);

  assertOriginalContent(plainDb);
  plainDb.close();

  assertEquals(SQLCipherUtils.State.UNENCRYPTED, SQLCipherUtils.getDatabaseState(ctxt, DB_NAME));

  factory = new SafeHelperFactory("".toCharArray());
  helper = factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME, new Callback(1));
  db = helper.getReadableDatabase();

  assertOriginalContent(db);

  db.close();
}
 
Example 24
Source Project: mimi-reader   Source File: ActiveAndroidSqlBriteBridge.java    License: Apache License 2.0 5 votes vote down vote up
public static BriteDatabase getBriteDatabase() {
    SupportSQLiteOpenHelper helper = getSQLiteOpenHelper();

    if (helper != null) {
        SqlBrite.Builder builder = new SqlBrite.Builder();
        SqlBrite sqlBrite = builder.build();
        return sqlBrite.wrapDatabaseHelper(helper, Schedulers.io());
    }

    return null;
}
 
Example 25
Source Project: sqlitemagic   Source File: DbDefaultConnectionTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void reInitClosesPrev() {
  final DbConnectionImpl dbConnection = SqliteMagic.getDefaultDbConnection();
  final SupportSQLiteOpenHelper dbHelper = dbConnection.dbHelper;
  final SupportSQLiteDatabase readableDatabase = dbHelper.getReadableDatabase();
  final SupportSQLiteDatabase writableDatabase = dbHelper.getWritableDatabase();

  initDbWithNewConnection();

  assertThat(readableDatabase.isOpen()).isFalse();
  assertThat(writableDatabase.isOpen()).isFalse();
  assertThat(dbConnection.triggers.hasObservers()).isFalse();
  assertThat(dbConnection.triggers.hasComplete()).isTrue();
}
 
Example 26
Source Project: sqlitemagic   Source File: SqliteMagic.java    License: Apache License 2.0 5 votes vote down vote up
static DbConnectionImpl openConnection(@NonNull Application context,
                                       @NonNull DatabaseSetupBuilder databaseSetupBuilder) {
  final Factory sqliteFactory = databaseSetupBuilder.sqliteFactory;
  if (sqliteFactory == null) {
    throw new NullPointerException("SQLite Factory cannot be null");
  }
  try {
    String name = databaseSetupBuilder.name;
    if (name == null || name.isEmpty()) {
      name = getDbName();
    }
    final int version = getDbVersion();
    final DbCallback dbCallback = new DbCallback(context, version, databaseSetupBuilder.downgrader);
    final Configuration configuration = Configuration
        .builder(context)
        .name(name)
        .callback(dbCallback)
        .build();
    final SupportSQLiteOpenHelper helper = sqliteFactory.create(configuration);
    LogUtil.logInfo("Initializing database with [name=%s, version=%s, logging=%s]",
        name, version, LOGGING_ENABLED);
    return new DbConnectionImpl(helper, databaseSetupBuilder.queryScheduler);
  } catch (Exception e) {
    throw new IllegalStateException("Error initializing database. " +
        "Make sure there is at least one model annotated with @Table", e);
  }
}
 
Example 27
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 28
/**
 * Creates a database configuration with the given values.
 *
 * @deprecated Use {@link #DatabaseConfiguration(Context, String,
 * SupportSQLiteOpenHelper.Factory, RoomDatabase.MigrationContainer, List, boolean,
 * RoomDatabase.JournalMode, Executor, Executor, boolean, boolean, boolean, Set, String, File)}
 *
 * @param context The application context.
 * @param name Name of the database, can be null if it is in memory.
 * @param sqliteOpenHelperFactory The open helper factory to use.
 * @param migrationContainer The migration container for migrations.
 * @param callbacks The list of callbacks for database events.
 * @param allowMainThreadQueries Whether to allow main thread reads/writes or not.
 * @param journalMode The journal mode. This has to be either TRUNCATE or WRITE_AHEAD_LOGGING.
 * @param queryExecutor The Executor used to execute asynchronous queries.
 * @param requireMigration True if Room should require a valid migration if version changes,
 *                        instead of recreating the tables.
 * @param migrationNotRequiredFrom The collection of schema versions from which migrations
 *                                 aren't required.
 *
 * @hide
 */
@Deprecated
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
public DatabaseConfiguration(@NonNull Context context, @Nullable String name,
        @NonNull SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory,
        @NonNull RoomDatabase.MigrationContainer migrationContainer,
        @Nullable List<androidx.room.RoomDatabase.Callback> callbacks,
        boolean allowMainThreadQueries,
        RoomDatabase.JournalMode journalMode,
        @NonNull Executor queryExecutor,
        boolean requireMigration,
        @Nullable Set<Integer> migrationNotRequiredFrom) {
    this(context, name, sqliteOpenHelperFactory, migrationContainer, callbacks,
            allowMainThreadQueries, journalMode, queryExecutor, queryExecutor, false,
            requireMigration, false, migrationNotRequiredFrom, null, null);
}
 
Example 29
/**
 * Creates a database configuration with the given values.
 *
 * @deprecated Use {@link #DatabaseConfiguration(Context, String,
 * SupportSQLiteOpenHelper.Factory, RoomDatabase.MigrationContainer, List, boolean,
 * RoomDatabase.JournalMode, Executor, Executor, boolean, boolean, boolean, Set, String, File)}
 *
 * @param context The application context.
 * @param name Name of the database, can be null if it is in memory.
 * @param sqliteOpenHelperFactory The open helper factory to use.
 * @param migrationContainer The migration container for migrations.
 * @param callbacks The list of callbacks for database events.
 * @param allowMainThreadQueries Whether to allow main thread reads/writes or not.
 * @param journalMode The journal mode. This has to be either TRUNCATE or WRITE_AHEAD_LOGGING.
 * @param queryExecutor The Executor used to execute asynchronous queries.
 * @param transactionExecutor The Executor used to execute asynchronous transactions.
 * @param multiInstanceInvalidation True if Room should perform multi-instance invalidation.
 * @param requireMigration True if Room should require a valid migration if version changes,
 * @param allowDestructiveMigrationOnDowngrade True if Room should recreate tables if no
 *                                             migration is supplied during a downgrade.
 * @param migrationNotRequiredFrom The collection of schema versions from which migrations
 *                                 aren't required.
 *
 * @hide
 */
@Deprecated
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
public DatabaseConfiguration(@NonNull Context context, @Nullable String name,
        @NonNull SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory,
        @NonNull RoomDatabase.MigrationContainer migrationContainer,
        @Nullable List<RoomDatabase.Callback> callbacks,
        boolean allowMainThreadQueries,
        RoomDatabase.JournalMode journalMode,
        @NonNull Executor queryExecutor,
        @NonNull Executor transactionExecutor,
        boolean multiInstanceInvalidation,
        boolean requireMigration,
        boolean allowDestructiveMigrationOnDowngrade,
        @Nullable Set<Integer> migrationNotRequiredFrom) {
    this(context, name, sqliteOpenHelperFactory, migrationContainer, callbacks,
            allowMainThreadQueries, journalMode, queryExecutor, transactionExecutor,
            multiInstanceInvalidation, requireMigration, allowDestructiveMigrationOnDowngrade,
            migrationNotRequiredFrom, null, null);
}
 
Example 30
Source Project: cwac-saferoom   Source File: SafeHelperFactory.java    License: Apache License 2.0 4 votes vote down vote up
public SupportSQLiteOpenHelper create(Context context, String name,
                                      SupportSQLiteOpenHelper.Callback callback) {
  return(new Helper(context, name, callback, passphrase, options));
}