当前位置: 首页>>代码示例>>Java>>正文


Java SQLiteOpenHelper类代码示例

本文整理汇总了Java中net.sqlcipher.database.SQLiteOpenHelper的典型用法代码示例。如果您正苦于以下问题:Java SQLiteOpenHelper类的具体用法?Java SQLiteOpenHelper怎么用?Java SQLiteOpenHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SQLiteOpenHelper类属于net.sqlcipher.database包,在下文中一共展示了SQLiteOpenHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: typeMappingShouldWorkWithSpecifiedTypeMappingFinder

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void typeMappingShouldWorkWithSpecifiedTypeMappingFinder() {
    TypeMappingFinder typeMappingFinder = new TypeMappingFinderImpl();
    //noinspection unchecked
    SQLiteTypeMapping<ClassEntity> typeMapping = SQLiteTypeMapping.builder()
            .putResolver(mock(PutResolver.class))
            .getResolver(mock(GetResolver.class))
            .deleteResolver(mock(DeleteResolver.class))
            .build();
    CipherStoreIO storIOSQLite = CipherStoreIO.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password")
            .typeMappingFinder(typeMappingFinder)
            .addTypeMapping(ClassEntity.class, typeMapping)
            .build();
    assertThat(storIOSQLite.lowLevel().typeMapping(ClassEntity.class)).isEqualTo(typeMapping);
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:17,代码来源:CipherStoreIOTest.java

示例2: typeMappingShouldWorkForMultipleTypes

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void typeMappingShouldWorkForMultipleTypes() {
    class AnotherEntity {
    }
    //noinspection unchecked
    SQLiteTypeMapping<ClassEntity> entityMapping = SQLiteTypeMapping.builder()
            .putResolver(mock(PutResolver.class))
            .getResolver(mock(GetResolver.class))
            .deleteResolver(mock(DeleteResolver.class))
            .build();
    //noinspection unchecked
    SQLiteTypeMapping<AnotherEntity> anotherMapping = SQLiteTypeMapping.builder()
            .putResolver(mock(PutResolver.class))
            .getResolver(mock(GetResolver.class))
            .deleteResolver(mock(DeleteResolver.class))
            .build();
    CipherStoreIO storIOSQLite = CipherStoreIO.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password")
            .addTypeMapping(ClassEntity.class, entityMapping)
            .addTypeMapping(AnotherEntity.class, anotherMapping)
            .build();
    assertThat(storIOSQLite.lowLevel().typeMapping(ClassEntity.class)).isEqualTo(entityMapping);
    assertThat(storIOSQLite.lowLevel().typeMapping(AnotherEntity.class)).isEqualTo(anotherMapping);
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:25,代码来源:CipherStoreIOTest.java

示例3: shouldPassSQLWithArgsToExecSQL

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void shouldPassSQLWithArgsToExecSQL() {
    SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
    SQLiteDatabase sqLiteDatabase = mock(SQLiteDatabase.class);
    when(sqLiteOpenHelper.getWritableDatabase("password")).thenReturn(sqLiteDatabase);
    StorIOSQLite storIOSQLite = CipherStoreIO.builder()
            .sqliteOpenHelper(sqLiteOpenHelper, "password")
            .build();
    RawQuery rawQuery = RawQuery.builder()
            .query("DROP TABLE users")
            .args("arg1", "arg2")
            .build();
    storIOSQLite
            .lowLevel()
            .executeSQL(rawQuery);
    verify(sqLiteOpenHelper).getWritableDatabase("password");
    verify(sqLiteDatabase).execSQL(eq(rawQuery.query()), eq(new String[]{"arg1", "arg2"}));
    verifyNoMoreInteractions(sqLiteOpenHelper, sqLiteDatabase);
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:20,代码来源:CipherStoreIOTest.java

示例4: shouldPassSQLWithoutArgsToExecSQL

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void shouldPassSQLWithoutArgsToExecSQL() {
    SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
    SQLiteDatabase sqLiteDatabase = mock(SQLiteDatabase.class);
    when(sqLiteOpenHelper.getWritableDatabase("password")).thenReturn(sqLiteDatabase);
    StorIOSQLite storIOSQLite = CipherStoreIO.builder()
            .sqliteOpenHelper(sqLiteOpenHelper, "password")
            .build();
    RawQuery rawQuery = RawQuery.builder()
            .query("DROP TABLE IF EXISTS someTable")
            .build(); // No args!
    storIOSQLite
            .lowLevel()
            .executeSQL(rawQuery);
    verify(sqLiteOpenHelper).getWritableDatabase("password");
    verify(sqLiteDatabase).execSQL(eq(rawQuery.query()));
    verifyNoMoreInteractions(sqLiteOpenHelper, sqLiteDatabase);
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:19,代码来源:CipherStoreIOTest.java

示例5: shouldPassArgsToInsertWithOnConflict

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void shouldPassArgsToInsertWithOnConflict() {
    SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
    SQLiteDatabase sqLiteDatabase = mock(SQLiteDatabase.class);
    when(sqLiteOpenHelper.getWritableDatabase("password")).thenReturn(sqLiteDatabase);
    StorIOSQLite storIOSQLite = CipherStoreIO.builder()
            .sqliteOpenHelper(sqLiteOpenHelper, "password")
            .build();
    InsertQuery insertQuery = InsertQuery.builder()
            .table("test_table")
            .nullColumnHack("custom_null_hack")
            .build();
    ContentValues contentValues = mock(ContentValues.class);
    int conflictAlgorithm = SQLiteDatabase.CONFLICT_ROLLBACK;
    storIOSQLite.lowLevel().insertWithOnConflict(insertQuery, contentValues, conflictAlgorithm);
    verify(sqLiteDatabase).insertWithOnConflict(
            eq("test_table"),
            eq("custom_null_hack"),
            same(contentValues),
            eq(SQLiteDatabase.CONFLICT_ROLLBACK)
    );
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:23,代码来源:CipherStoreIOTest.java

示例6: notifyAboutChangesShouldNotAcceptNullAsChanges

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void notifyAboutChangesShouldNotAcceptNullAsChanges() {
    SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
    StorIOSQLite storIOSQLite = CipherStoreIO.builder()
            .sqliteOpenHelper(sqLiteOpenHelper, "password")
            .build();
    StorIOSQLite.LowLevel lowLevel = storIOSQLite.lowLevel();
    assertThat(lowLevel).isNotNull();
    try {
        //noinspection ConstantConditions
        lowLevel.notifyAboutChanges(null);
        failBecauseExceptionWasNotThrown(NullPointerException.class);
    } catch (NullPointerException expected) {
        assertThat(expected).hasMessage("Changes can not be null");
    }
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:17,代码来源:CipherStoreIOTest.java

示例7: observeChangesAndNotifyAboutChangesShouldWorkCorrectly

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void observeChangesAndNotifyAboutChangesShouldWorkCorrectly() {
    SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
    StorIOSQLite storIOSQLite = CipherStoreIO.builder()
            .sqliteOpenHelper(sqLiteOpenHelper, "password")
            .build();
    TestSubscriber<Changes> testSubscriber = new TestSubscriber<>();
    storIOSQLite
            .observeChanges()
            .subscribe(testSubscriber);
    testSubscriber.assertNoValues();
    Changes changes = Changes.newInstance("test_table");
    storIOSQLite
            .lowLevel()
            .notifyAboutChanges(changes);
    testSubscriber.assertValue(changes);
    testSubscriber.assertNoErrors();
    testSubscriber.unsubscribe();
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:20,代码来源:CipherStoreIOTest.java

示例8: BriteDatabase

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
BriteDatabase(Context context,SQLiteOpenHelper helper, @NonNull char[] password, Logger logger, Observable<Set<String>> triggerSource,
    Observer<Set<String>> triggerSink, Scheduler scheduler,
    ObservableTransformer<Query, Query> queryTransformer) {
  SQLiteDatabase.loadLibs(context);
  this.helper = helper;
  this.password = password;
  this.logger = logger;
  this.triggerSource = triggerSource;
  this.triggerSink = triggerSink;
  this.scheduler = scheduler;
  this.queryTransformer = queryTransformer;
}
 
开发者ID:jiechic,项目名称:sqlbrite-sqlcipher,代码行数:13,代码来源:BriteDatabase.java

示例9: provideDatabase

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Provides
@Singleton
BriteDatabase provideDatabase(Application application, SqlBrite sqlBrite, SQLiteOpenHelper helper) {
    BriteDatabase db = sqlBrite.wrapDatabaseHelper(application.getApplicationContext(), helper, PASSWORD, Schedulers.io());
    db.setLoggingEnabled(true);
    return db;
}
 
开发者ID:jiechic,项目名称:sqlbrite-sqlcipher,代码行数:8,代码来源:DbModule.java

示例10: CipherStoreIO

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
protected CipherStoreIO(
        @NonNull SQLiteOpenHelper sqLiteOpenHelper,
        @NonNull TypeMappingFinder typeMappingFinder,
        @NonNull String password,
        @Nullable Scheduler defaultScheduler
) {
    this.sqLiteOpenHelper = sqLiteOpenHelper;
    this.defaultScheduler = defaultScheduler;
    this.password = password;
    lowLevel = new LowLevelImpl(typeMappingFinder);
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:12,代码来源:CipherStoreIO.java

示例11: addTypeMappingNullType

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void addTypeMappingNullType() {
    CipherStoreIO.CompleteBuilder builder = CipherStoreIO.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password");
    expectedException.expect(NullPointerException.class);
    expectedException.expectMessage(equalTo("Please specify type"));
    expectedException.expectCause(nullValue(Throwable.class));
    //noinspection unchecked,ConstantConditions
    builder.addTypeMapping(null, SQLiteTypeMapping.builder()
            .putResolver(mock(PutResolver.class))
            .getResolver(mock(GetResolver.class))
            .deleteResolver(mock(DeleteResolver.class))
            .build());
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:15,代码来源:CipherStoreIOTest.java

示例12: addTypeMappingNullMapping

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void addTypeMappingNullMapping() {
    CipherStoreIO.CompleteBuilder builder = CipherStoreIO.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password");
    expectedException.expect(NullPointerException.class);
    expectedException.expectMessage(equalTo("Please specify type mapping"));
    expectedException.expectCause(nullValue(Throwable.class));
    //noinspection ConstantConditions
    builder.addTypeMapping(Object.class, null);
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:11,代码来源:CipherStoreIOTest.java

示例13: nullTypeMappingFinder

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void nullTypeMappingFinder() {
    CipherStoreIO.CompleteBuilder builder = CipherStoreIO.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password");
    expectedException.expect(NullPointerException.class);
    expectedException.expectMessage(equalTo("Please specify typeMappingFinder"));
    expectedException.expectCause(nullValue(Throwable.class));
    //noinspection ConstantConditions
    builder.typeMappingFinder(null);
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:11,代码来源:CipherStoreIOTest.java

示例14: shouldUseSpecifiedTypeMappingFinder

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void shouldUseSpecifiedTypeMappingFinder() throws NoSuchFieldException, IllegalAccessException {
    TypeMappingFinder typeMappingFinder = mock(TypeMappingFinder.class);
    CipherStoreIO storIOSQLite = CipherStoreIO.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password")
            .typeMappingFinder(typeMappingFinder)
            .build();
    assertThat(getTypeMappingFinder(storIOSQLite)).isEqualTo(typeMappingFinder);
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:10,代码来源:CipherStoreIOTest.java

示例15: typeMappingShouldWorkWithoutSpecifiedTypeMappingFinder

import net.sqlcipher.database.SQLiteOpenHelper; //导入依赖的package包/类
@Test
public void typeMappingShouldWorkWithoutSpecifiedTypeMappingFinder() {
    //noinspection unchecked
    SQLiteTypeMapping<ClassEntity> typeMapping = SQLiteTypeMapping.builder()
            .putResolver(mock(PutResolver.class))
            .getResolver(mock(GetResolver.class))
            .deleteResolver(mock(DeleteResolver.class))
            .build();
    CipherStoreIO storIOSQLite = CipherStoreIO.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class), "password")
            .addTypeMapping(ClassEntity.class, typeMapping)
            .build();
    assertThat(storIOSQLite.lowLevel().typeMapping(ClassEntity.class)).isEqualTo(typeMapping);
}
 
开发者ID:pbochenski,项目名称:CipherStorIO,代码行数:15,代码来源:CipherStoreIOTest.java


注:本文中的net.sqlcipher.database.SQLiteOpenHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。