我在一个小项目中使用 db4o,该项目在 Android 2.2、2.3 等上运行良好。但是,在 Honeycomb 上,数据库初始化会导致以下错误:
com.db4o.ext.Db4oException: File format incompatible: '/data/data/com.myapp/app_data/my_app.db4o'
在运行 Honeycomb 的 Xoom 和运行 Honeycomb 的 Galaxy Tab 上都会发生此强制关闭和错误。
相关代码为:
public ObjectContainer db() {
// Create, open, and close the database
try {
if (oc == null || oc.ext().isClosed()) {
oc = Db4oEmbedded
.openFile(dbConfig(), db4oDBFullPath(mContext));
}
return oc;
} catch (Exception e) {
Log.e(CFAApplication.TAG, e.toString());
return null;
}
}
private String db4oDBFullPath(Context ctx) {
// Returns the path for the database location
return ctx.getDir("data", 2) + "/" + "myapp.db4o";
}
public List<MyItem> getListItem(final String passedItemTitle) {
List<MyItem> result = db().query(new Predicate<MyItem>() { // Error occurs here
public boolean match(MyItem listItem) {
if (passedItemTitle.equals(listItem.getTitle())) {
return true;
}
return false;
}
});
return result;
}
Honeycomb 处理其外部文件系统的方式有什么不同吗?我可以在 db4oDBFullPath() 方法中更改任何内容以使两者兼容吗?我真的不知道发生了什么不同的事情。也许我需要启用一些 Honeycomb 特定的权限?
最佳答案
关于android - hive 上的 db4o Db4oException : File format incompatible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7085089/