Android的我可以使用JOIN在mediastore查询可以使用、Android、mediastore、JOIN

2023-09-05 00:39:26 作者:被温柔宠坏

有没有使用在一次查询时mediastore数据的方法?

is there any method to use join in a query at mediastore data?

或者也有没有通过数据库和不访问mediastore数据与内容提供商的方法?

Or also is there any method to access the mediastore data through a database and not with the content provider?

感谢你。

推荐答案

不过,我认为,你可以使用连接与内容提供商。如果你把两个查询,您可以通过使用CursorJoiner加入他们的行列。我用它和它的作品很好。

But I think that you can use joins with content providers. If you make two queries, you can join them by using CursorJoiner. I am using it and it works good.

片段从Android的文档:

Snippet from Android docs:

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连接相同,但它是有用的。在每一个案例,你可以用两个光标这是指向处理过的行处理。

it is not exactly the same as SQL join but its useful. In each "case" you can manipulate with both cursors which are pointing to processed row.