Android Can I use JOIN at mediastore query

这一生的挚爱 提交于 2019-11-28 05:43:16

问题


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 provider?

Thank you.


回答1:


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.




回答2:


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

There are no JOINs possible with content provider queries, sorry.

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

Only if you write your own firmware.



来源:https://stackoverflow.com/questions/6526212/android-can-i-use-join-at-mediastore-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!