本文整理汇总了Java中android.arch.persistence.db.SupportSQLiteOpenHelper类的典型用法代码示例。如果您正苦于以下问题:Java SupportSQLiteOpenHelper类的具体用法?Java SupportSQLiteOpenHelper怎么用?Java SupportSQLiteOpenHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SupportSQLiteOpenHelper类属于android.arch.persistence.db包,在下文中一共展示了SupportSQLiteOpenHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: tearDownDatabase
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@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();
}
}
}
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:21,代码来源:SafeRoomCompatTestSuite.java
示例2: rekey
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@Test
public void rekey() throws IOException {
SafeHelperFactory factory=
SafeHelperFactory.fromUser(new SpannableStringBuilder("sekrit"));
SupportSQLiteOpenHelper helper=
factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME, 1,
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, 1,
new Callback(1));
db=helper.getWritableDatabase();
assertUpdatedContent(db);
}
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:23,代码来源:RekeyTest.java
示例3: setUp
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@Before public void setUp() throws IOException {
Configuration configuration = Configuration.builder(InstrumentationRegistry.getContext())
.callback(testDb)
.name(dbFolder.newFile().getPath())
.build();
Factory factory = new FrameworkSQLiteOpenHelperFactory();
SupportSQLiteOpenHelper helper = factory.create(configuration);
real = helper.getWritableDatabase();
SqlBrite.Logger logger = new SqlBrite.Logger() {
@Override public void log(String message) {
logs.add(message);
}
};
ObservableTransformer<Query, Query> queryTransformer =
new ObservableTransformer<Query, Query>() {
@Override public ObservableSource<Query> apply(Observable<Query> upstream) {
return upstream.takeUntil(killSwitch);
}
};
db = new BriteDatabase(helper, logger, scheduler, queryTransformer);
}
开发者ID:square,项目名称:sqlbrite,代码行数:24,代码来源:BriteDatabaseTest.java
示例4: AutoContentProvider
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
public AutoContentProvider(ContentHelper contentHelper, Logger logger, SupportSQLiteOpenHelperFactoryProvider supportSQLiteOpenHelperFactoryProvider) {
this.logger = logger != null ? logger : Logger.EmptyLogger.INSTANCE;
this.contentHelper = contentHelper;
this.supportSQLiteOpenHelperFactoryProvider = supportSQLiteOpenHelperFactoryProvider;
defaultCallback = new SupportSQLiteOpenHelper.Callback(contentHelper.DATABASE_VERSION) {
@Override
public void onCreate(SupportSQLiteDatabase db) {
onCreateDataBase(db);
}
@Override
public void onUpgrade(SupportSQLiteDatabase db, int oldVersion, int newVersion) {
onUpgradeDatabase(db, oldVersion, newVersion);
}
};
}
开发者ID:SelvinPL,项目名称:SyncFrameworkAndroid,代码行数:17,代码来源:AutoContentProvider.java
示例5: create
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@Override
public SupportSQLiteOpenHelper create(SupportSQLiteOpenHelper.Configuration configuration) {
return new AssetSQLiteOpenHelper(
configuration.context, configuration.name, null,
configuration.version, configuration.errorHandler, configuration.callback
);
}
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:8,代码来源:AssetSQLiteOpenHelperFactory.java
示例6: create
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public SupportSQLiteOpenHelper create(
SupportSQLiteOpenHelper.Configuration configuration) {
return(create(configuration.context, configuration.name,
configuration.callback.version, configuration.callback));
}
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:10,代码来源:SafeHelperFactory.java
示例7: Helper
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
Helper(Context context, String name, int version,
SupportSQLiteOpenHelper.Callback callback, char[] passphrase) {
SQLiteDatabase.loadLibs(context);
delegate=createDelegate(context, name, version, callback);
this.passphrase=passphrase;
this.name=name;
}
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:8,代码来源:Helper.java
示例8: reInitClosesPrev
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@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();
}
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:15,代码来源:DbDefaultConnectionTest.java
示例9: DbConnectionImpl
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
DbConnectionImpl(@NonNull SupportSQLiteOpenHelper dbHelper, @NonNull Scheduler queryScheduler) {
this.dbHelper = dbHelper;
this.queryScheduler = queryScheduler;
final int nrOfTables = getNrOfTables();
final EntityDbManager[] cachedEntityData = new EntityDbManager[nrOfTables];
for (int i = 0; i < nrOfTables; i++) {
cachedEntityData[i] = new EntityDbManager(this);
}
this.entityDbManagers = cachedEntityData;
}
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:11,代码来源:DbConnectionImpl.java
示例10: openConnection
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
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);
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);
}
}
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:28,代码来源:SqliteMagic.java
示例11: BriteDatabase
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
BriteDatabase(SupportSQLiteOpenHelper helper, Logger logger, Scheduler scheduler,
ObservableTransformer<Query, Query> queryTransformer) {
this.helper = helper;
this.logger = logger;
this.scheduler = scheduler;
this.queryTransformer = queryTransformer;
}
开发者ID:square,项目名称:sqlbrite,代码行数:8,代码来源:BriteDatabase.java
示例12: setUp
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@Before public void setUp() {
Configuration configuration = Configuration.builder(InstrumentationRegistry.getContext())
.callback(new TestDb())
.build();
Factory factory = new FrameworkSQLiteOpenHelperFactory();
SupportSQLiteOpenHelper helper = factory.create(configuration);
SqlBrite sqlBrite = new SqlBrite.Builder().build();
db = sqlBrite.wrapDatabaseHelper(helper, Schedulers.trampoline());
}
开发者ID:square,项目名称:sqlbrite,代码行数:12,代码来源:QueryTest.java
示例13: provideDatabase
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@Provides @Singleton BriteDatabase provideDatabase(SqlBrite sqlBrite, Application application) {
Configuration configuration = Configuration.builder(application)
.name("todo.db")
.callback(new DbCallback())
.build();
Factory factory = new FrameworkSQLiteOpenHelperFactory();
SupportSQLiteOpenHelper helper = factory.create(configuration);
BriteDatabase db = sqlBrite.wrapDatabaseHelper(helper, Schedulers.io());
db.setLoggingEnabled(true);
return db;
}
开发者ID:square,项目名称:sqlbrite,代码行数:12,代码来源:DbModule.java
示例14: TestProvider
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
public TestProvider() {
super(CONTENT_HELPER, Logger.EmptyLogger.INSTANCE,
new SupportSQLiteOpenHelperFactoryProvider() {
@Override
public SupportSQLiteOpenHelper.Factory createFactory(Context context) {
return new FrameworkSQLiteOpenHelperFactory();
}
});
}
开发者ID:SelvinPL,项目名称:SyncFrameworkAndroid,代码行数:10,代码来源:TestProvider.java
示例15: getFactory
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@Override
public SupportSQLiteOpenHelper.Factory getFactory() {
return SafeHelperFactory.fromUser(new SpannableStringBuilder("sekrit"));
}
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:5,代码来源:SafeRoomCompatTestSuite.java
示例16: create
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
/**
* @deprecated use {@link io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory} instead
*/
@Deprecated
@Override
public SupportSQLiteOpenHelper create(SupportSQLiteOpenHelper.Configuration config) {
return factory.create(config);
}
开发者ID:gabrielittner,项目名称:support-db-requery,代码行数:9,代码来源:RequerySQLiteOpenHelperFactory.java
示例17: create
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@Override
public SupportSQLiteOpenHelper create(Configuration config) {
return new CallbackSQLiteOpenHelper(config.context, config.name, config.callback);
}
开发者ID:requery,项目名称:sqlite-android,代码行数:5,代码来源:RequerySQLiteOpenHelperFactory.java
示例18: createFactory
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@Override
public SupportSQLiteOpenHelper.Factory createFactory(Context context) {
return new SqlCipherOpenHelperFactory("test");
}
开发者ID:SelvinPL,项目名称:SyncFrameworkAndroid,代码行数:5,代码来源:HelperFactoryProvider.java
示例19: createFactory
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@Override
public SupportSQLiteOpenHelper.Factory createFactory(Context context) {
return new FrameworkSQLiteOpenHelperFactory();
}
开发者ID:SelvinPL,项目名称:SyncFrameworkAndroid,代码行数:5,代码来源:HelperFactoryProvider.java
示例20: create
import android.arch.persistence.db.SupportSQLiteOpenHelper; //导入依赖的package包/类
@Override
public SupportSQLiteOpenHelper create(SupportSQLiteOpenHelper.Configuration configuration) {
SQLiteDatabase.loadLibs(configuration.context);
return new SqlCipherOpenHelper(
configuration.context, configuration.name, configuration.callback, password);
}
开发者ID:SelvinPL,项目名称:SyncFrameworkAndroid,代码行数:7,代码来源:SqlCipherOpenHelperFactory.java
注:本文中的android.arch.persistence.db.SupportSQLiteOpenHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论