android - 是否可以使用 Android Room 数据库创建 R*Tree 表?

标签 android database entity android-room r-tree

我想继续使用 Room,但我看不到如何创建使用 rtree 的实体。有 @FTS3 和 @FTS4 注释,但我没有看到 RTree 的注释。是否可以使用 R-Tree 创建实体?

我尝试使用此代码进行迁移,但我仍然没有 Room 的实体...

val TABLE_CREATE = "CREATE VIRTUAL TABLE if not exists my_table_name USING rtree(" +
       "row_id," +          // Primary key
       "minX, maxX," +      // Minimum and maximum X coordinate
       "minY, maxY" +       // Minimum and maximum Y coordinate
");"
db.execSQL(TABLE_CREATE)

最佳答案

我认为目前不可能在 Room 中使用 RTree。

要使用 RTree,您需要使用选项 -DSQLITE_ENABLE_RTREE=1 编译的 SQLite 发行版。

Room 是 SQLite 上的一个抽象层,随 Android 设备一起分发,我相信它没有启用 RTree(如果是的话,我猜@RTree 注释将可用)。

例如在 API 31 上,如果您尝试使用您会得到:-

E/SQLiteLog: (1) statement aborts at 28: [CREATE VIRTUAL TABLE rtree1 USING rtree(id,minX,maxX,minY,maxY);] no such module: rtree

即rtree 未启用。

关于android - 是否可以使用 Android Room 数据库创建 R*Tree 表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69593568/

相关文章:

php - 从 MySQL 中获取查询并将其打印在 javascript 日历中

xcode - 未使用的实体问题 : Expression result unused XCode 4

java - TreeMap 比较器没有给出预期的顺序?

android - 如何添加取决于 ListView 中 TextView 文本的 ImageView

android - 使用 WebView 的 Jetpack 导航无法正常工作

java - 适用于 Android 的 catmull-rom 样条

如果文本太长,Mysql 数据库不会保存文本

mysql合并数据分配相同的ID

c# - linq to entity 中的奇怪结果

android - 在 Ionic 上使用 Android 的 history.back()