本文整理汇总了Java中com.orm.androrm.DatabaseAdapter.renameTable方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseAdapter.renameTable方法的具体用法?Java DatabaseAdapter.renameTable怎么用?Java DatabaseAdapter.renameTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orm.androrm.DatabaseAdapter
的用法示例。
在下文中一共展示了DatabaseAdapter.renameTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}