本文整理汇总了Java中com.orm.androrm.DatabaseAdapter.setDatabaseName方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseAdapter.setDatabaseName方法的具体用法?Java DatabaseAdapter.setDatabaseName怎么用?Java DatabaseAdapter.setDatabaseName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orm.androrm.DatabaseAdapter
的用法示例。
在下文中一共展示了DatabaseAdapter.setDatabaseName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: initializeDatabase
import com.orm.androrm.DatabaseAdapter; //导入方法依赖的package包/类
/**
* 初始化数据库
* 两个表:一个是搜索历史,一个是收藏
*/
private void initializeDatabase() {
List<Class<? extends Model>> models = new ArrayList<>(0);
models.add(SearchHistory.class);
models.add(Favorites.class);
String dbName = this.getResources().getString(R.string.database_name);
DatabaseAdapter.setDatabaseName(dbName);
DatabaseAdapter adapter = new DatabaseAdapter(sAppContext);
adapter.setModels(models);
}
示例5: CacheManager
import com.orm.androrm.DatabaseAdapter; //导入方法依赖的package包/类
public CacheManager(Context context) {
this.context = context;
/**
* Set the database name and init the database adapter.
*/
DatabaseAdapter.setDatabaseName(DATABASE_NAME);
databaseAdapter = DatabaseAdapter.getInstance(context);
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(Cache.class);
databaseAdapter.setModels(models);
}
示例6: DatabaseManager
import com.orm.androrm.DatabaseAdapter; //导入方法依赖的package包/类
public DatabaseManager(Context context, String dbName) {
this.context = context;
DatabaseAdapter.setDatabaseName(dbName);
adapter = DatabaseAdapter.getInstance(context);
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(PortalsInfo.class);
adapter.setModels(models);
adapter.beginTransaction();
}
示例7: syncDB
import com.orm.androrm.DatabaseAdapter; //导入方法依赖的package包/类
public static void syncDB(Context app) {
final String DB_NAME = "sm.db";
List<Class<? extends Model>> models =
new ArrayList<Class<? extends Model>>();
SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(app);
int dbVersion = prefs.getInt(PREF_VERSION, 0);
//int dbVersion = 0;
Log.d(SMApp.TAG, "syncing DB, version " + dbVersion);
models.add(Book.class);
models.add(Scripture.class);
DatabaseAdapter.setDatabaseName(DB_NAME);
DatabaseAdapter.getInstance(app)
.setModels(models);
if (Book.objects(app).count() == 0) {
if (app.getDatabasePath(DBHandler.DB_NAME).exists()) {
migrate(app);
} else {
populate(app);
prefs.edit().putInt(PREF_VERSION, VERSION).apply();
dbVersion = VERSION;
}
}
if (dbVersion < VERSION) {
upgrade(app, dbVersion);
prefs.edit().putInt(PREF_VERSION, VERSION).apply();
}
Log.d(SMApp.TAG, "done syncing DB");
}