androidx.sqlite.db.SupportSQLiteOpenHelper Java Examples

The following examples show how to use androidx.sqlite.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: PostHookSqlTest.java    From cwac-saferoom with 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 #2
Source File: CloseThenOpenTest.java    From cwac-saferoom with 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 #3
Source File: ActiveAndroidSqlBriteBridge.java    From mimi-reader with 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 #4
Source File: CloseThenOpenTest.java    From cwac-saferoom with 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 File: CloseThenOpenTest.java    From cwac-saferoom with 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 #6
Source File: PassphraseClearTest.java    From cwac-saferoom with 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 #7
Source File: RekeyTest.java    From cwac-saferoom with 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 #8
Source File: RekeyTest.java    From cwac-saferoom with 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 File: SafeFactoryProvider.java    From cwac-saferoom with 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 #10
Source File: PassphraseClearTest.java    From cwac-saferoom with 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 #11
Source File: EncryptTest.java    From cwac-saferoom with 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 #12
Source File: WALTest.java    From cwac-saferoom with 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 #13
Source File: SQLiteCopyOpenHelperFactory.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
SQLiteCopyOpenHelperFactory(
        @Nullable String copyFromAssetPath,
        @Nullable File copyFromFile,
        @NonNull SupportSQLiteOpenHelper.Factory factory) {
    mCopyFromAssetPath = copyFromAssetPath;
    mCopyFromFile = copyFromFile;
    mDelegate = factory;
}
 
Example #14
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 #15
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 #16
Source File: DecryptTest.java    From cwac-saferoom with 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 #17
Source File: ActiveAndroidSqlBriteBridge.java    From mimi-reader with 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 #18
Source File: DbDefaultConnectionTest.java    From sqlitemagic with 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 #19
Source File: SqliteMagic.java    From sqlitemagic with 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 #20
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 #21
Source File: DatabaseConfiguration.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #22
Source File: SQLiteCopyOpenHelperFactory.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
@Override
public SupportSQLiteOpenHelper create(SupportSQLiteOpenHelper.Configuration configuration) {
    return new SQLiteCopyOpenHelper(
            configuration.context,
            mCopyFromAssetPath,
            mCopyFromFile,
            configuration.callback.version,
            mDelegate.create(configuration));
}
 
Example #23
Source File: PostHookSqlTest.java    From cwac-saferoom with 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 #24
Source File: SQLiteCopyOpenHelper.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source File: SafeHelperFactory.java    From cwac-saferoom with 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 #26
Source File: PostHookSqlTest.java    From cwac-saferoom with 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 #27
Source File: PreHookSqlTest.java    From cwac-saferoom with 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 #28
Source File: RequerySQLiteOpenHelperFactory.java    From sqlite-android with Apache License 2.0 4 votes vote down vote up
CallbackSQLiteOpenHelper(Context context, String name, SupportSQLiteOpenHelper.Callback cb, Iterable<ConfigurationOptions> ops) {
    super(context, name, null, cb.version, new CallbackDatabaseErrorHandler(cb));
    this.callback = cb;
    this.configurationOptions = ops;
}
 
Example #29
Source File: KriptonSQLCipherHelperFactory.java    From kripton with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public SupportSQLiteOpenHelper create(SupportSQLiteOpenHelper.Configuration configuration) {
	return (create(configuration.context, configuration.name, configuration.callback));
}
 
Example #30
Source File: KriptonSQLiteHelperFactory.java    From kripton with Apache License 2.0 4 votes vote down vote up
@Override
public SupportSQLiteOpenHelper create(Configuration configuration) {
	return new KriptonSQLiteHelper(configuration);
}