【问题标题】:Android Can I use JOIN at mediastore query我可以在 mediastore 查询中使用 JOIN
【发布时间】:2011-09-25 10:54:49
【问题描述】:

有什么方法可以在媒体存储数据的查询中使用联接?

或者还有什么方法可以通过数据库而不是通过内容提供者来访问媒体存储数据?

谢谢。

【问题讨论】:

    标签: java android join mediastore


    【解决方案1】:

    但我认为您可以使用内容提供者的联接。如果您进行两个查询,您可以使用 CursorJoiner 将它们连接起来。我正在使用它,效果很好。

    来自 Android 文档的片段:

    CursorJoiner joiner = new CursorJoiner(cursorA, keyColumnsofA, cursorB, keyColumnsofB);
     for (CursorJointer.Result joinerResult : joiner) {
         switch (joinerResult) {
             case LEFT:
                 // handle case where a row in cursorA is unique
                 break;
             case RIGHT:
                 // handle case where a row in cursorB is unique
                 break;
             case BOTH:
                 // handle case where a row with the same key is in both cursors
                 break;
         }
     }
    

    它与 SQL 连接并不完全相同,但它很有用。在每种“情况”中,您都可以使用指向已处理行的两个游标进行操作。

    【讨论】:

      【解决方案2】:

      有什么方法可以在媒体存储数据的查询中使用联接?

      内容提供者查询无法进行 JOIN,抱歉。

      或者还有什么方法可以通过数据库而不是通过内容提供者来访问媒体存储数据?

      仅当您编写自己的固件时。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-08-15
        • 2017-06-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多