本文整理汇总了Java中com.orm.androrm.DatabaseAdapter类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseAdapter类的具体用法?Java DatabaseAdapter怎么用?Java DatabaseAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseAdapter类属于com.orm.androrm包,在下文中一共展示了DatabaseAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: syncDB
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
/**
* Tell AndOrm about the Models that will be used to read and write to the database.
*/
public void syncDB() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(GameSession.class);
models.add(MarketRequest.class);
models.add(RequestItem.class);
models.add(InventoryItem.class);
models.add(DefaultTile.class);
models.add(LetterTile.class);
models.add(WordTile.class);
models.add(LetterBuilder.class);
models.add(WordTileBuilder.class);
models.add(WordBuilder.class);
models.add(WorkshopBuilder.class);
models.add(GameTile.class);
models.add(GameTileBuilder.class);
models.add(GameTileTimer.class);
models.add(DecorationTile.class);
DatabaseAdapter.setDatabaseName("game_db");
DatabaseAdapter adapter = DatabaseAdapter.getInstance(PhoeniciaContext.context);
adapter.setModels(models);
}
示例2: setUp
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
PhoeniciaContext.context = getContext();
assertNotNull("Null context", PhoeniciaContext.context);
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(GameSession.class);
DatabaseAdapter.setDatabaseName("game_db");
DatabaseAdapter adapter = DatabaseAdapter.getInstance(PhoeniciaContext.context);
adapter.setModels(models);
this.session = new GameSession();
session.session_name.set("test session");
session.locale_pack.set("test-locale");
session.current_level.set("test-level");
session.save(PhoeniciaContext.context);
assertNotNull(session.getId());
Bank.init(session);
}
示例3: setUp
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
public void setUp() throws Exception {
super.setUp();
PhoeniciaContext.context = getContext();
assertNotNull("Null context", PhoeniciaContext.context);
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(GameSession.class);
models.add(InventoryItem.class);
DatabaseAdapter.setDatabaseName("game_db");
DatabaseAdapter adapter = DatabaseAdapter.getInstance(PhoeniciaContext.context);
adapter.setModels(models);
GameSession session = new GameSession();
session.session_name.set("test session");
session.locale_pack.set("test-locale");
session.current_level.set("test-level");
session.save(PhoeniciaContext.context);
assertNotNull(session.getId());
Inventory.init(session);
}
示例4: exec
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
protected boolean exec(Context context, Class<? extends Model> model, String sql) {
DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
adapter.open();
try {
adapter.exec(sql);
} catch(SQLException e) {
adapter.close();
return false;
}
adapter.close();
return true;
}
示例5: deleteGroup
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
private void deleteGroup() {
Context app = getApplication();
DatabaseAdapter adapter = DatabaseAdapter.getInstance(app);
Filter f;
adapter.beginTransaction();
for (Scripture scrip : deleteBook.getScriptures(app).all()) {
scrip.delete(app);
}
f = new Filter().is("position", ">", deleteBook.getPosition());
for (Book book : Book.objects(app).filter(f)) {
book.setPosition(book.getPosition() - 1);
book.save(app);
}
deleteBook.delete(app);
adapter.commitTransaction();
buildList();
Toast.makeText(this, R.string.group_deleted,
Toast.LENGTH_SHORT).show();
}
示例6: migrate
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
private static void migrate(Context app) {
List<BookRecord> books;
Book book;
Scripture scrip;
DatabaseAdapter adapter = DatabaseAdapter.getInstance(app);
books = getOldBooks(app);
adapter.beginTransaction();
for (BookRecord bookRecord : books) {
book = new Book();
Log.d(SMApp.TAG, "migrating " + bookRecord.title);
book.setTitle(bookRecord.title);
book.setPreloaded(bookRecord.preloaded);
for (ScripRecord scripRecord : bookRecord.scriptures) {
scrip = new Scripture(scripRecord.ref,
scripRecord.keywords, scripRecord.verses,
scripRecord.status, scripRecord.finishedStreak);
book.addScripture(scrip);
scrip.save(app);
}
book.setRoutine(bookRecord, app);
book.save(app);
}
adapter.commitTransaction();
app.deleteDatabase(DBHandler.DB_NAME);
}
示例7: execute
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public boolean execute(Context context, Class<T> model) {
if(isApplied(model, context)) {
return false;
}
MigrationHelper helper = new MigrationHelper(context);
if(!helper.tableExists(mOldName)) {
// if the table, that should be renamed doesn't exist anymore
// we have to assume, that this migration is rolled out on
// a newer version of the database. Thus we need to save, that
// it has already been applied, but must not run the command
// on the database.
return true;
}
DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
renameRelationTables(context, model);
try {
adapter.renameTable(mOldName, getValue(model));
} catch (SQLException e) {
return false;
}
return true;
}
示例8: execute
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public boolean execute(Context context, Class<T> model) {
MigrationHelper helper = new MigrationHelper(context);
List<String> tables = helper.getRelationTableNames(mOldName);
String newName = DatabaseBuilder.getTableName(model);
mValue = StringUtils.join(tables, ",");
if(isApplied(model, context)) {
return false;
}
DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
for(String table : tables) {
List<String> parts = Arrays.asList(table.replace(mOldName, newName).split("_"));
Collections.sort(parts);
String name = StringUtils.join(parts, "_");
try {
adapter.renameTable(table, name);
} catch(SQLException e) {
return false;
}
}
return true;
}
示例9: setUp
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class);
models.add(OneFieldModel.class);
models.add(ModelWithRelation.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
super.setUp();
}
示例10: setUp
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
super.setUp();
}
示例11: setUp
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class);
models.add(ModelWithRelation.class);
models.add(NewEmptyModel.class);
models.add(NewModelWithRelation.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
super.setUp();
}
示例12: testMigrationsRun
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
public void testMigrationsRun() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(ModelWithMigration.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
assertTrue(mHelper.hasField(ModelWithMigration.class, "mTestField"));
}
示例13: setUp
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(BlankModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
示例14: setUp
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(Product.class);
models.add(Branch.class);
models.add(Brand.class);
models.add(Supplier.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
示例15: setUp
import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(Brand.class);
models.add(Branch.class);
models.add(Product.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}