本文整理汇总了Java中com.orm.androrm.DatabaseAdapter.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseAdapter.getInstance方法的具体用法?Java DatabaseAdapter.getInstance怎么用?Java DatabaseAdapter.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orm.androrm.DatabaseAdapter
的用法示例。
在下文中一共展示了DatabaseAdapter.getInstance方法的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: 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;
}
示例3: 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();
}
示例4: 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);
}
示例5: setUp
import com.orm.androrm.DatabaseAdapter; //导入方法依赖的package包/类
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(Car.class);
models.add(Person.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
示例6: 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(Supplier.class);
models.add(Branch.class);
models.add(Brand.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
示例7: 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(Supplier.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
示例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);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
super.setUp();
}
示例10: 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"));
}
示例11: 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);
}
示例12: 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);
}
示例13: testTableDefinitionCache
import com.orm.androrm.DatabaseAdapter; //导入方法依赖的package包/类
public void testTableDefinitionCache() {
assertFalse(ModelCache.knowsModel(Product.class));
assertNull(ModelCache.getTableDefinitions(Product.class));
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(Product.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
assertTrue(ModelCache.knowsModel(Product.class));
assertNotNull(ModelCache.getTableDefinitions(Product.class));
}
示例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(Supplier.class);
models.add(Brand.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
Brand b = new Brand();
b.setName("Copcal");
b.save(getContext());
// ID 1
Branch b1 = new Branch();
b1.setName("Cashbuild Pretoria");
b1.setBrand(b);
b1.save(getContext());
// ID 2
Branch b2 = new Branch();
b2.setName("Plumblink Pretoria");
b2.setBrand(b);
b2.save(getContext());
// ID 3
Branch b3 = new Branch();
b3.setName("The third Branch");
b3.setBrand(b);
b3.save(getContext());
}
示例15: testFieldShortcur
import com.orm.androrm.DatabaseAdapter; //导入方法依赖的package包/类
public void testFieldShortcur() {
assertNull(ModelCache.getField(BlankModelNoAutoincrement.class, "mName"));
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(BlankModelNoAutoincrement.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
assertNotNull(ModelCache.getField(BlankModelNoAutoincrement.class, "mName"));
}