如何更新Android中的DBFlow?

时间:2015-05-08 20:36:08

标签: android orm sql-update flow update-statement

我实现了上面的代码,这是DBFlow教程中的代码

Update<Ant> update = new Update().table(Ant.class).set(Condition.column(Ant$Table.TYPE).eq("other"))
  .where(Condition.column(Ant$Table.TYPE).is("worker"))
  .and(Condition.column(Ant$Table.ISMALE).is(true));
update.queryClose();

Update()queryClose()变成红色。

实际上,在DBFlow的Update类中,甚至没有出现我刚刚粘贴的代码中显示的方法table()。

有人知道如何实现Update语句吗?谢谢

3 个答案:

答案 0 :(得分:1)

我在Update()queryClose()遇到了同样的问题,我通过使用像这样的对象更新数据库解决了这个问题

&#13;
&#13;
mObject.setType("other");
mObject.update();
&#13;
&#13;
&#13;

答案 1 :(得分:0)

您拥有的查询将返回Where对象。然后,您的Where对象将采用.queryClose()方法。

Where update = new Update().table(Ant.class).set(Condition.column(Ant$Table.TYPE).eq("other"))
  .where(Condition.column(Ant$Table.TYPE).is("worker"))
  .and(Condition.column(Ant$Table.ISMALE).is(true));
update.queryClose();

答案 2 :(得分:0)

您需要将Java版本从1.6升级到1.7。

以防Android Studio - &gt;在应用程序文件夹中打开gradle.build并修复它们

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

文档仍旧,然后使用它:

Where update = new Update<>(Ant.class).set(Condition.column(Ant$Table.TYPE).eq("other"))
  .where(Condition.column(Ant$Table.TYPE).is("worker"))
  .and(Condition.column(Ant$Table.ISMALE).is(true));
update.queryClose();