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


Java DatabaseAdapter.getInstance方法代码示例

本文整理汇总了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);
}
 
开发者ID:XPRIZE,项目名称:GLEXP-Team-The-Linguaculturalists,代码行数:26,代码来源:GameActivity.java

示例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;
}
 
开发者ID:XPRIZE,项目名称:GLEXP-Team-The-Linguaculturalists,代码行数:17,代码来源:DataField.java

示例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();
}
 
开发者ID:tooke7,项目名称:sm-helper,代码行数:20,代码来源:MainActivity.java

示例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);
}
 
开发者ID:tooke7,项目名称:sm-helper,代码行数:27,代码来源:SyncDB.java

示例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);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:10,代码来源:ForeignKeyRegression.java

示例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);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:12,代码来源:ManyToManyFieldTest.java

示例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);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:11,代码来源:FilterTest.java

示例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;
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:31,代码来源:RenameRelationMigration.java

示例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();
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:11,代码来源:DataFieldMigrationTest.java

示例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"));
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:10,代码来源:ModelTest.java

示例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);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:9,代码来源:TransactionTest.java

示例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);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:9,代码来源:ModelRegression.java

示例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));
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:14,代码来源:TableDefinitionCacheTest.java

示例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());
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:34,代码来源:QuerySetTest.java

示例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"));
}
 
开发者ID:XPRIZE,项目名称:GLEXP-Team-The-Linguaculturalists,代码行数:12,代码来源:FieldCacheTest.java


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