Android Can I use JOIN at mediastore query

后端 未结 2 1887
隐瞒了意图╮
隐瞒了意图╮ 2020-12-20 02:03

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

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

2条回答
  •  醉酒成梦
    2020-12-20 02:32

    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.

    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;
         }
     }
    

    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.

提交回复
热议问题